Re: How to control the order of the images

  •  04-29-2013, 12:04 PM

    Re: How to control the order of the images

    Hi bertsirkin,

     

    The steps below shows you how to sort the image by your own logic in classic alyout.

     

    Please follow the steps below. Step 1- step 4 use to sort the order for the classic layout. Step 5 –step 7 use to sort the viwer. Step 2 and step 6 is the sort logic.


    1.      Open file “\CuteSoft_Client\Gallery\Layout\Classic\Code.js”


    2.      Add the code below to the top


    function BubbleSort(arr) {
        var temp;
        var exchange;
        for (var i = 0; i < arr.length; i++) {
            exchange = false;
            for (var j = arr.length - 2; j >= i; j--) {
                if ((arr[j + 1].Thumbnail) > (arr[j].Thumbnail)) {
                    temp = arr[j + 1];
                    arr[j + 1] = arr[j];
                    arr[j] = temp;
                    exchange = true;
                }
            }
            if (!exchange) {
                break;
            }
        }
        return arr;
    }


    3.      Find section below


          for(var i=0;i<this._categories.length;i++)
          {
                photos=photos.concat(this._categories[i].Photos);
          }


    4.      Change it to


          for(var i=0;i<this._categories.length;i++)
          {
                photos=photos.concat(this._categories[i].Photos);
          }
          photos = BubbleSort(photos);


    5.      Open file “\CuteSoft_Client\Gallery\Viewer\LightBox\Code.js”


    6.      Add the code below to the top


    function BubbleSort(arr) {
        var temp;
        var exchange;
        for (var i = 0; i < arr.length; i++) {
            exchange = false;
            for (var j = arr.length - 2; j >= i; j--) {
                if ((arr[j + 1].Thumbnail) > (arr[j].Thumbnail)) {
                    temp = arr[j + 1];
                    arr[j + 1] = arr[j];
                    arr[j] = temp;
                    exchange = true;
                }
            }
            if (!exchange) {
                break;
            }
        }
        return arr;
    }
    7.      Find section below


          for(var i=0;i<cs.length;i++)
          {
                photos=photos.concat(cs[i].Photos);
          }
    8.      Change it to


          for(var i=0;i<cs.length;i++)
          {
                photos=photos.concat(cs[i].Photos);
          }
          photos = BubbleSort(photos);


     

    Regards,

     

    Ken 

View Complete Thread