Version Description
New: Feed based on liked media (Pro)
Fixed: Hidden media in last page
Fixed: Minor issues
Download this release
Release Info
Developer | webdorado |
Plugin | WD Instagram Feed – Instagram Gallery |
Version | 1.1.12 |
Comparing to | |
See all releases |
Code changes from version 1.1.11 to 1.1.12
- admin-functions.php +1 -0
- admin/controllers/WDIControllerFeeds_wdi.php +4 -0
- admin/models/WDIModelFeeds_wdi.php +3 -1
- admin/views/WDIViewFeeds_wdi.php +1 -0
- frontend/shortcode.php +8 -4
- frontend/views/WDIViewImageBrowser_view.php +1 -1
- frontend/views/WDIViewThumbnails_view.php +1 -0
- js/wdi_admin.js +8 -0
- js/wdi_frontend.js +905 -704
- js/wdi_instagram.js +444 -346
- js/wdi_responsive.js +269 -275
- readme.txt +6 -1
- update/wdi_update.php +3 -1
- wd-instagram-feed.php +2 -2
admin-functions.php
CHANGED
@@ -168,6 +168,7 @@ function wdi_install(){
|
|
168 |
conditional_filter_type varchar(32) NOT NULL,
|
169 |
show_username_on_thumb varchar(32) NOT NULL,
|
170 |
conditional_filter_enable varchar(1) NOT NULL,
|
|
|
171 |
UNIQUE KEY id (id)
|
172 |
) $charset_collate;";
|
173 |
|
168 |
conditional_filter_type varchar(32) NOT NULL,
|
169 |
show_username_on_thumb varchar(32) NOT NULL,
|
170 |
conditional_filter_enable varchar(1) NOT NULL,
|
171 |
+
liked_feed varchar(30) NOT NULL,
|
172 |
UNIQUE KEY id (id)
|
173 |
) $charset_collate;";
|
174 |
|
admin/controllers/WDIControllerFeeds_wdi.php
CHANGED
@@ -107,6 +107,7 @@ class WDIControllerFeeds_wdi {
|
|
107 |
'%s',//'conditional_filter_type' => 'string'
|
108 |
'%d',/*show_username_on_thumb*/
|
109 |
'%d',//'conditional_filter_enable'=>'0',
|
|
|
110 |
);
|
111 |
}
|
112 |
private function display() {
|
@@ -448,6 +449,9 @@ private function check_settings($settings){
|
|
448 |
if($settings['conditional_filter_enable'] == '1'){
|
449 |
$settings['conditional_filter_enable'] = '0';
|
450 |
}
|
|
|
|
|
|
|
451 |
return $settings;
|
452 |
}
|
453 |
|
107 |
'%s',//'conditional_filter_type' => 'string'
|
108 |
'%d',/*show_username_on_thumb*/
|
109 |
'%d',//'conditional_filter_enable'=>'0',
|
110 |
+
'%s',//'liked_feed' => 'string'
|
111 |
);
|
112 |
}
|
113 |
private function display() {
|
449 |
if($settings['conditional_filter_enable'] == '1'){
|
450 |
$settings['conditional_filter_enable'] = '0';
|
451 |
}
|
452 |
+
if($settings['liked_feed'] == 'liked'){
|
453 |
+
$settings['liked_feed'] = 'userhash';
|
454 |
+
}
|
455 |
return $settings;
|
456 |
}
|
457 |
|
admin/models/WDIModelFeeds_wdi.php
CHANGED
@@ -141,6 +141,7 @@ class WDIModelFeeds_wdi {
|
|
141 |
'conditional_filter_type' => 'none',
|
142 |
'show_username_on_thumb'=>'0',
|
143 |
'conditional_filter_enable'=>'0',
|
|
|
144 |
);
|
145 |
return $settings;
|
146 |
}
|
@@ -208,7 +209,8 @@ class WDIModelFeeds_wdi {
|
|
208 |
|
209 |
'conditional_filters' => 'string',
|
210 |
'conditional_filter_enable'=>'number',
|
211 |
-
'conditional_filter_type' => 'string'
|
|
|
212 |
);
|
213 |
return $sanitize_types;
|
214 |
}
|
141 |
'conditional_filter_type' => 'none',
|
142 |
'show_username_on_thumb'=>'0',
|
143 |
'conditional_filter_enable'=>'0',
|
144 |
+
'liked_feed' => 'userhash',
|
145 |
);
|
146 |
return $settings;
|
147 |
}
|
209 |
|
210 |
'conditional_filters' => 'string',
|
211 |
'conditional_filter_enable'=>'number',
|
212 |
+
'conditional_filter_type' => 'string',
|
213 |
+
'liked_feed' => 'string',
|
214 |
);
|
215 |
return $sanitize_types;
|
216 |
}
|
admin/views/WDIViewFeeds_wdi.php
CHANGED
@@ -208,6 +208,7 @@ public function getFormElements($current_id=''){
|
|
208 |
$elements = array(
|
209 |
'feed_name' => array('name'=>'feed_name','title'=>__('Feed Name',"wdi"),'type'=>'input','tooltip'=>__('The name of your feed which can be displayed in feed\'s header section',"wdi"),'attr'=>array(array('name'=>'tab','value'=>'feed_settings'),array('name'=>'section','value'=>'thumbnails,masonry,blog_style,image_browser'))),
|
210 |
'theme_id' => array('switched'=>'off','label'=>array('place'=>'after','class'=>'wdi_pro_only','text'=>__("Changing Theme is Available Only in PRO version","wdi"),'br'=>'true'),'name' =>'theme_id', 'title'=>__('Theme',"wdi"),'valid_options'=>$themes,'type'=>'select','tooltip'=>__('The theme of your feed, you can create themes in themes menu',"wdi"),'attr'=>array(array('name'=>'tab','value'=>'feed_settings'),array('name'=>'section','value'=>'thumbnails,masonry,blog_style,image_browser'))),
|
|
|
211 |
'feed_users' => array('name'=>'feed_users','title'=>__('Feed Usernames and Hashtags',"wdi"),'type'=>'input','input_type'=>'hidden','tooltip'=>__('Enter usernames or hashtags to your feed, hashtags must start with #, username\'s shouldn\'t start with @',"wdi"),'attr'=>array(array('name'=>'tab','value'=>'feed_settings'),array('name'=>'section','value'=>'thumbnails,masonry,blog_style,image_browser'))),
|
212 |
'thumb_user' => array('name' =>'thumb_user', 'title'=>__('Featured Image',"wdi"),'valid_options'=>array(),'type'=>'select','tooltip'=>__('Select Featured Image For Header Section',"wdi"),'attr'=>array(array('name'=>'tab','value'=>'feed_settings'),array('name'=>'section','value'=>'thumbnails,masonry,blog_style,image_browser'))),
|
213 |
'feed_display_view' => array('name'=>'feed_display_view','title'=>__('Feed Display Type',"wdi"),'type'=>'radio','valid_options'=>array('pagination'=>__('Pagination',"wdi"),'load_more_btn'=>__('Load More Button',"wdi"),'infinite_scroll'=>__('Infinite Scroll',"wdi")),'disabled_options'=>array('infinite_scroll'=>__('This Feature is Available in PRO version'),'br'=>'true'),'break'=>'true','hide_ids'=>array('pagination'=>'number_of_photos,load_more_number,resort_after_load_more','load_more_btn'=>'pagination_per_page_number,pagination_preload_number','infinite_scroll'=>'pagination_per_page_number,pagination_preload_number'),'tooltip'=>__('How to load and display new images',"wdi"),'attr'=>array(array('name'=>'tab','value'=>'feed_settings'),array('name'=>'section','value'=>'thumbnails,masonry,blog_style'))),
|
208 |
$elements = array(
|
209 |
'feed_name' => array('name'=>'feed_name','title'=>__('Feed Name',"wdi"),'type'=>'input','tooltip'=>__('The name of your feed which can be displayed in feed\'s header section',"wdi"),'attr'=>array(array('name'=>'tab','value'=>'feed_settings'),array('name'=>'section','value'=>'thumbnails,masonry,blog_style,image_browser'))),
|
210 |
'theme_id' => array('switched'=>'off','label'=>array('place'=>'after','class'=>'wdi_pro_only','text'=>__("Changing Theme is Available Only in PRO version","wdi"),'br'=>'true'),'name' =>'theme_id', 'title'=>__('Theme',"wdi"),'valid_options'=>$themes,'type'=>'select','tooltip'=>__('The theme of your feed, you can create themes in themes menu',"wdi"),'attr'=>array(array('name'=>'tab','value'=>'feed_settings'),array('name'=>'section','value'=>'thumbnails,masonry,blog_style,image_browser'))),
|
211 |
+
'liked_feed' => array('switched'=>'off', 'disabled_options'=>array('liked'=>__('Feed of liked media is Available in PRO version'),'br'=>'true'), 'name'=>'liked_feed','title'=>__('User/Hashtag feed or liked media',"wdi"),'type'=>'radio','valid_options'=>array('userhash'=>__('Username/Hashtag',"wdi"),'liked'=>__('Media I liked',"wdi")),'break'=>'false','hide_ids'=>array('liked'=>'feed_users,thumb_user'),'tooltip'=>__('Show the media I liked instead of showing user or hashtag feed',"wdi"),'attr'=>array(array('name'=>'tab','value'=>'feed_settings'),array('name'=>'section','value'=>'thumbnails,masonry,blog_style,image_browser'))),
|
212 |
'feed_users' => array('name'=>'feed_users','title'=>__('Feed Usernames and Hashtags',"wdi"),'type'=>'input','input_type'=>'hidden','tooltip'=>__('Enter usernames or hashtags to your feed, hashtags must start with #, username\'s shouldn\'t start with @',"wdi"),'attr'=>array(array('name'=>'tab','value'=>'feed_settings'),array('name'=>'section','value'=>'thumbnails,masonry,blog_style,image_browser'))),
|
213 |
'thumb_user' => array('name' =>'thumb_user', 'title'=>__('Featured Image',"wdi"),'valid_options'=>array(),'type'=>'select','tooltip'=>__('Select Featured Image For Header Section',"wdi"),'attr'=>array(array('name'=>'tab','value'=>'feed_settings'),array('name'=>'section','value'=>'thumbnails,masonry,blog_style,image_browser'))),
|
214 |
'feed_display_view' => array('name'=>'feed_display_view','title'=>__('Feed Display Type',"wdi"),'type'=>'radio','valid_options'=>array('pagination'=>__('Pagination',"wdi"),'load_more_btn'=>__('Load More Button',"wdi"),'infinite_scroll'=>__('Infinite Scroll',"wdi")),'disabled_options'=>array('infinite_scroll'=>__('This Feature is Available in PRO version'),'br'=>'true'),'break'=>'true','hide_ids'=>array('pagination'=>'number_of_photos,load_more_number,resort_after_load_more','load_more_btn'=>'pagination_per_page_number,pagination_preload_number','infinite_scroll'=>'pagination_per_page_number,pagination_preload_number'),'tooltip'=>__('How to load and display new images',"wdi"),'attr'=>array(array('name'=>'tab','value'=>'feed_settings'),array('name'=>'section','value'=>'thumbnails,masonry,blog_style'))),
|
frontend/shortcode.php
CHANGED
@@ -25,6 +25,7 @@ function wdi_feed($atts,$widget_params='') {
|
|
25 |
'id' => 'no_id',
|
26 |
), $atts );
|
27 |
if ($attributes['id']=='no_id'){
|
|
|
28 |
return __('Invalid shortcode', "wdi");
|
29 |
}
|
30 |
|
@@ -40,13 +41,13 @@ function wdi_feed($atts,$widget_params='') {
|
|
40 |
//checking if access token is not set or removed display proper error message
|
41 |
global $wdi_options;
|
42 |
if(!isset($wdi_options['wdi_access_token']) || $wdi_options['wdi_access_token']==''){
|
|
|
43 |
return __('Access Token is invalid, please get it again ', "wdi");
|
44 |
-
die();
|
45 |
}
|
46 |
|
47 |
if(!isset($feed_row) || $feed_row==NULL){
|
|
|
48 |
return __('Feed Doesn\'t exists ',"wdi");
|
49 |
-
die();
|
50 |
}
|
51 |
|
52 |
|
@@ -69,8 +70,8 @@ function wdi_feed($atts,$widget_params='') {
|
|
69 |
}
|
70 |
|
71 |
if(isset($feed_row['published']) && $feed_row['published']=== '0'){
|
|
|
72 |
return __('Unable to display unpublished feed ',"wdi");
|
73 |
-
die();
|
74 |
}
|
75 |
//checking feed type and using proper MVC
|
76 |
$feed_type = isset($feed_row['feed_type']) ? $feed_row['feed_type'] : '';
|
@@ -91,8 +92,11 @@ function wdi_feed($atts,$widget_params='') {
|
|
91 |
$wdi_feed_counter++;
|
92 |
break;
|
93 |
}
|
94 |
-
default:
|
|
|
95 |
return __('Invalid feed type', "wdi");
|
|
|
|
|
96 |
}
|
97 |
|
98 |
|
25 |
'id' => 'no_id',
|
26 |
), $atts );
|
27 |
if ($attributes['id']=='no_id'){
|
28 |
+
ob_get_clean();
|
29 |
return __('Invalid shortcode', "wdi");
|
30 |
}
|
31 |
|
41 |
//checking if access token is not set or removed display proper error message
|
42 |
global $wdi_options;
|
43 |
if(!isset($wdi_options['wdi_access_token']) || $wdi_options['wdi_access_token']==''){
|
44 |
+
ob_get_clean();
|
45 |
return __('Access Token is invalid, please get it again ', "wdi");
|
|
|
46 |
}
|
47 |
|
48 |
if(!isset($feed_row) || $feed_row==NULL){
|
49 |
+
ob_get_clean();
|
50 |
return __('Feed Doesn\'t exists ',"wdi");
|
|
|
51 |
}
|
52 |
|
53 |
|
70 |
}
|
71 |
|
72 |
if(isset($feed_row['published']) && $feed_row['published']=== '0'){
|
73 |
+
ob_get_clean();
|
74 |
return __('Unable to display unpublished feed ',"wdi");
|
|
|
75 |
}
|
76 |
//checking feed type and using proper MVC
|
77 |
$feed_type = isset($feed_row['feed_type']) ? $feed_row['feed_type'] : '';
|
92 |
$wdi_feed_counter++;
|
93 |
break;
|
94 |
}
|
95 |
+
default:{
|
96 |
+
ob_get_clean();
|
97 |
return __('Invalid feed type', "wdi");
|
98 |
+
}
|
99 |
+
|
100 |
}
|
101 |
|
102 |
|
frontend/views/WDIViewImageBrowser_view.php
CHANGED
@@ -285,7 +285,7 @@ public function generate_feed_styles($feed_row){
|
|
285 |
|
286 |
#wdi_feed_<?php echo $wdi_feed_counter?> .wdi_photo_wrap {
|
287 |
padding: <?php echo $style['image_browser_photo_wrap_padding']?>; /*photo_wrap_padding*/
|
288 |
-
|
289 |
overflow: hidden;
|
290 |
}
|
291 |
#wdi_feed_<?php echo $wdi_feed_counter?> .wdi_photo_wrap_inner{
|
285 |
|
286 |
#wdi_feed_<?php echo $wdi_feed_counter?> .wdi_photo_wrap {
|
287 |
padding: <?php echo $style['image_browser_photo_wrap_padding']?>; /*photo_wrap_padding*/
|
288 |
+
box-sizing:content-box;
|
289 |
overflow: hidden;
|
290 |
}
|
291 |
#wdi_feed_<?php echo $wdi_feed_counter?> .wdi_photo_wrap_inner{
|
frontend/views/WDIViewThumbnails_view.php
CHANGED
@@ -298,6 +298,7 @@ public function generate_feed_styles($feed_row){
|
|
298 |
position: relative;
|
299 |
width: calc(100% - 2*<?php echo $style['th_photo_wrap_padding']?>);
|
300 |
display: inline-block;
|
|
|
301 |
overflow: hidden;
|
302 |
}
|
303 |
#wdi_feed_<?php echo $wdi_feed_counter?> .wdi_photo_wrap:after{
|
298 |
position: relative;
|
299 |
width: calc(100% - 2*<?php echo $style['th_photo_wrap_padding']?>);
|
300 |
display: inline-block;
|
301 |
+
box-sizing:content-box;
|
302 |
overflow: hidden;
|
303 |
}
|
304 |
#wdi_feed_<?php echo $wdi_feed_counter?> .wdi_photo_wrap:after{
|
js/wdi_admin.js
CHANGED
@@ -1219,6 +1219,14 @@ wdi_controller.updateConditionalFiltersUi = function(){
|
|
1219 |
* Updates Conditinal filter source
|
1220 |
*/
|
1221 |
wdi_controller.updateFilterSource = function(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1222 |
var users = [],
|
1223 |
username,
|
1224 |
userThumb;
|
1219 |
* Updates Conditinal filter source
|
1220 |
*/
|
1221 |
wdi_controller.updateFilterSource = function(){
|
1222 |
+
|
1223 |
+
if(jQuery('input[name="wdi_feed_settings[liked_feed]"]:checked').val() == 'liked'){
|
1224 |
+
var sourceDiv = jQuery('#wdi_filter_source').html('');
|
1225 |
+
var singleUserHtml = "<div class='wdi_source_user'><span class='wdi_source_username'>Media I liked</span></div>";
|
1226 |
+
sourceDiv.html(sourceDiv.html() + singleUserHtml);
|
1227 |
+
return;
|
1228 |
+
}
|
1229 |
+
|
1230 |
var users = [],
|
1231 |
username,
|
1232 |
userThumb;
|
js/wdi_frontend.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
-
|
2 |
if (typeof wdi_front == 'undefined') {
|
3 |
wdi_front = {
|
4 |
type: 'not_declared'
|
5 |
};
|
6 |
}
|
7 |
-
jQuery(document).ready(function()
|
|
|
8 |
if (wdi_front['type'] != 'not_declared') {
|
9 |
wdi_front.clickOrTouch = wdi_front.detectEvent();
|
10 |
//initializing all feeds in the page
|
@@ -16,7 +16,8 @@ jQuery(document).ready(function() {
|
|
16 |
});
|
17 |
|
18 |
|
19 |
-
wdi_front.detectEvent = function()
|
|
|
20 |
var isMobile = (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()));
|
21 |
if (isMobile) {
|
22 |
return "touchend";
|
@@ -25,11 +26,11 @@ wdi_front.detectEvent = function() {
|
|
25 |
}
|
26 |
}
|
27 |
|
28 |
-
wdi_front.globalInit = function()
|
|
|
29 |
var num = wdi_front['feed_counter'];
|
30 |
|
31 |
|
32 |
-
|
33 |
for (var i = 0; i <= num; i++) {
|
34 |
|
35 |
var currentFeed = new WDIFeed(window['wdi_feed_' + i]);
|
@@ -45,22 +46,37 @@ wdi_front.globalInit = function() {
|
|
45 |
feed: currentFeed
|
46 |
};
|
47 |
|
48 |
-
currentFeed.instagram.filters = [
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
}
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
|
66 |
currentFeed.instagram.addToken(currentFeed['feed_row']['access_token']);
|
@@ -87,14 +103,13 @@ wdi_front.globalInit = function() {
|
|
87 |
currentFeed.customFilterChanged = false; //flag to notice filter change, onclick on username
|
88 |
|
89 |
|
90 |
-
|
91 |
/**
|
92 |
* This variable describes after how many requests program will stop searching for content
|
93 |
* this number is very important and should not be set too high, because when feed has conditional filter
|
94 |
* and filtered items are rare then the program will recursively request new photos and will filter them
|
95 |
* if no image was fount it will go into infinite loop if feed images are "infinite" ( very huge number )
|
96 |
* and if requests count in 1 hour exeed 5000 instagram will block access token for one hour
|
97 |
-
*
|
98 |
* @type {Number}
|
99 |
*/
|
100 |
currentFeed.maxConditionalFiltersRequestCount = 10;
|
@@ -102,7 +117,7 @@ wdi_front.globalInit = function() {
|
|
102 |
/**
|
103 |
* This variable shows us how many times program has been recursively called,
|
104 |
* it changes it value within filtering function, and resets itself to 0 when feed is being displayed
|
105 |
-
*
|
106 |
* @type {Number}
|
107 |
*/
|
108 |
currentFeed.instagramRequestCounter = 0;
|
@@ -111,7 +126,7 @@ wdi_front.globalInit = function() {
|
|
111 |
* This array stores data from each request,
|
112 |
* it is used to determine and remove duplicate photos caused by multiple hashtags
|
113 |
* it is resetted to its inital [] value after displaying feed
|
114 |
-
*
|
115 |
* @type {Array}
|
116 |
*/
|
117 |
currentFeed.conditionalFilterBuffer = [];
|
@@ -119,7 +134,8 @@ wdi_front.globalInit = function() {
|
|
119 |
|
120 |
currentFeed.stopInfiniteScrollFlag = false;
|
121 |
|
122 |
-
window.onload = function()
|
|
|
123 |
for (var i = 0; i <= wdi_front.feed_counter; i++) {
|
124 |
window['wdi_feed_' + i]['nowLoadingImages'] = false;
|
125 |
}
|
@@ -130,7 +146,6 @@ wdi_front.globalInit = function() {
|
|
130 |
}
|
131 |
|
132 |
|
133 |
-
|
134 |
//if pagination is on then set pagination parameters
|
135 |
if (currentFeed.feed_row.feed_display_view == 'pagination') {
|
136 |
currentFeed.feed_row.resort_after_load_more = 0;
|
@@ -150,10 +165,11 @@ wdi_front.globalInit = function() {
|
|
150 |
|
151 |
|
152 |
//initializing function for lightbox
|
153 |
-
currentFeed.galleryBox = function(image_id)
|
154 |
-
|
155 |
-
|
156 |
-
|
|
|
157 |
wdi_responsive.columnControl(currentFeed);
|
158 |
|
159 |
//if feed type is masonry then trigger resize event for building proper column layout
|
@@ -166,46 +182,54 @@ wdi_front.globalInit = function() {
|
|
166 |
window['wdi_feed_' + i] = currentFeed;
|
167 |
|
168 |
|
169 |
-
|
170 |
//initializing each feed
|
171 |
wdi_front.init(currentFeed);
|
172 |
} //endfor
|
173 |
|
174 |
}
|
175 |
|
176 |
-
wdi_front.init = function(currentFeed)
|
|
|
177 |
|
178 |
|
179 |
//some varables used in code
|
180 |
currentFeed.photoCounter = currentFeed.feed_row["number_of_photos"];
|
181 |
|
182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
* Check if feed user has no id for some reason then update user
|
193 |
-
* and after updating them initialize feed
|
194 |
-
*/
|
195 |
-
if ( wdi_front.updateUsersIfNecessary( currentFeed ) ){
|
196 |
-
return;
|
197 |
-
};
|
198 |
|
199 |
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
|
205 |
|
206 |
//wdi_front.loadInstagramMedia( currentFeed, currentFeed.feed_row.number_of_photos);
|
207 |
-
|
208 |
-
|
|
|
|
|
|
|
209 |
wdi_front.instagramRequest(i, currentFeed);
|
210 |
}
|
211 |
|
@@ -227,13 +251,13 @@ wdi_front.init = function(currentFeed) {
|
|
227 |
}
|
228 |
|
229 |
|
230 |
-
|
231 |
/**
|
232 |
* Checks if given string is JSON string
|
233 |
* @param {String} str [string to check]
|
234 |
* @return {Boolean} [true or false]
|
235 |
*/
|
236 |
-
wdi_front.isJsonString = function(str)
|
|
|
237 |
try {
|
238 |
JSON.parse(str);
|
239 |
} catch (e) {
|
@@ -243,52 +267,63 @@ wdi_front.isJsonString = function(str) {
|
|
243 |
}
|
244 |
|
245 |
|
246 |
-
|
247 |
/**
|
248 |
* Makes an ajax request for given user from feed_users array
|
249 |
* if response is ok then calls saveUserData function
|
|
|
250 |
* @param {Number} id [index of user in current_feed.feed_users array]
|
251 |
-
* @param {Object} currentFeed
|
252 |
*/
|
253 |
-
wdi_front.instagramRequest = function(id, currentFeed)
|
|
|
254 |
|
255 |
var feed_users = currentFeed.feed_users,
|
256 |
_this = this;
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
{
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
_this.saveUserData(response, currentFeed.feed_users[id], currentFeed);
|
266 |
-
}
|
267 |
-
}
|
268 |
-
});
|
269 |
-
break;
|
270 |
}
|
271 |
-
|
272 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
273 |
currentFeed.instagram.getUserRecentMedia(feed_users[id]['id'], {
|
274 |
-
success: function(response)
|
|
|
275 |
response = _this.checkMediaResponse(response);
|
276 |
if (response != false) {
|
277 |
_this.saveUserData(response, currentFeed.feed_users[id], currentFeed);
|
278 |
}
|
279 |
}
|
280 |
-
})
|
281 |
-
break;
|
282 |
}
|
283 |
-
|
284 |
}
|
285 |
|
286 |
/**
|
287 |
* Returns true is given string starts with dash ( # )
|
288 |
-
* @param {String} str
|
289 |
* @return {Boolean} [true or false]
|
290 |
*/
|
291 |
-
wdi_front.isHashtag = function(str)
|
|
|
292 |
return (str[0] === '#');
|
293 |
}
|
294 |
|
@@ -297,7 +332,8 @@ wdi_front.isHashtag = function(str) {
|
|
297 |
* Saves each user data on seperate index in currentFeed.usersData array
|
298 |
* And also checks if all data form all users is already avialable if yes it displays feed
|
299 |
*/
|
300 |
-
wdi_front.saveUserData = function(data, user, currentFeed)
|
|
|
301 |
|
302 |
data['username'] = user.username;
|
303 |
data['user_id'] = user.id;
|
@@ -316,16 +352,14 @@ wdi_front.saveUserData = function(data, user, currentFeed) {
|
|
316 |
currentFeed.allResponseLength += currentFeed.currentResponseLength;
|
317 |
|
318 |
|
319 |
-
|
320 |
if (currentFeed.dataCount == currentFeed.usersData.length) {
|
321 |
|
322 |
//if getted objects is not enough then recuest new ones
|
323 |
-
|
324 |
if (currentFeed.currentResponseLength < currentFeed.feed_row.number_of_photos && !wdi_front.userHasNoPhoto(currentFeed)) {
|
325 |
//console.log('initial recursion');
|
326 |
/*here we are calling loadMore function out of recursion cylce, after this initial-keep call
|
327 |
-
|
328 |
-
|
329 |
|
330 |
wdi_front.loadMore('initial-keep', currentFeed);
|
331 |
} else {
|
@@ -335,16 +369,73 @@ wdi_front.saveUserData = function(data, user, currentFeed) {
|
|
335 |
wdi_front.displayFeed(currentFeed);
|
336 |
//when all data us properly displayed check for any active filters and then apply them
|
337 |
wdi_front.applyFilters(currentFeed);
|
338 |
-
|
339 |
|
340 |
/*removing load more button of feed has finished*/
|
341 |
-
if(
|
342 |
if (currentFeed.feed_row.feed_display_view == 'load_more_btn') {
|
343 |
var feed_container = jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter);
|
344 |
feed_container.find('.wdi_load_more').addClass('wdi_hidden');
|
345 |
feed_container.find('.wdi_spinner').addClass('wdi_hidden');
|
346 |
}
|
347 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
348 |
|
349 |
}
|
350 |
|
@@ -356,16 +447,26 @@ wdi_front.saveUserData = function(data, user, currentFeed) {
|
|
356 |
/**
|
357 |
* checks weather all feed users have any photos after first time request
|
358 |
*/
|
359 |
-
wdi_front.userHasNoPhoto = function(currentFeed, cstData)
|
|
|
|
|
360 |
var counter = 0;
|
361 |
var data = currentFeed.usersData;
|
362 |
-
if (cstData != undefined) {
|
363 |
data = cstData;
|
364 |
}
|
365 |
for (var i = 0; i < data.length; i++) {
|
366 |
-
if (
|
367 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
368 |
}
|
|
|
369 |
}
|
370 |
if (counter == data.length) {
|
371 |
return 1;
|
@@ -377,7 +478,8 @@ wdi_front.userHasNoPhoto = function(currentFeed, cstData) {
|
|
377 |
/*
|
378 |
*gives each instagram object custom hashtag parameter, which is used for searching image/video
|
379 |
*/
|
380 |
-
wdi_front.appendRequestHashtag = function(data, hashtag)
|
|
|
381 |
for (var i = 0; i < data.length; i++) {
|
382 |
data[i]['wdi_hashtag'] = hashtag;
|
383 |
}
|
@@ -385,14 +487,13 @@ wdi_front.appendRequestHashtag = function(data, hashtag) {
|
|
385 |
}
|
386 |
|
387 |
|
388 |
-
|
389 |
/*
|
390 |
* sorts data based on user choice and displays feed
|
391 |
* also checks if one request is not enough for displaying all images user wanted
|
392 |
* it recursively calls wdi_front.loadMore() until the desired number of photos is reached
|
393 |
*/
|
394 |
-
wdi_front.displayFeed = function(currentFeed, load_more_number)
|
395 |
-
|
396 |
|
397 |
|
398 |
if (currentFeed.customFilterChanged == false) {
|
@@ -432,21 +533,20 @@ wdi_front.displayFeed = function(currentFeed, load_more_number) {
|
|
432 |
}
|
433 |
|
434 |
//checking feed_type and calling proper rendering functions
|
435 |
-
if (
|
436 |
wdi_front.masonryDisplayFeedItems(data, currentFeed);
|
437 |
}
|
438 |
-
if (
|
439 |
-
wdi_front.displayFeedItems(
|
440 |
}
|
441 |
|
442 |
|
443 |
-
|
444 |
//recursively calling load more to get photos
|
445 |
-
var dataLength = wdi_front.getDataLength(
|
446 |
|
447 |
|
448 |
-
if (
|
449 |
-
wdi_front.loadMore(
|
450 |
|
451 |
} else {
|
452 |
wdi_front.allImagesLoaded(currentFeed);
|
@@ -456,7 +556,7 @@ wdi_front.displayFeed = function(currentFeed, load_more_number) {
|
|
456 |
/**
|
457 |
* if maximum number of requests are reached then stop laoding more images and show images which are available
|
458 |
* @param {Number} currentFeed.instagramRequestCounter > currentFeed.maxConditionalFiltersRequestCount [description]
|
459 |
-
* @return {Boolean}
|
460 |
*/
|
461 |
if (currentFeed.instagramRequestCounter > currentFeed.maxConditionalFiltersRequestCount) {
|
462 |
wdi_front.allImagesLoaded(currentFeed);
|
@@ -476,7 +576,6 @@ wdi_front.displayFeed = function(currentFeed, load_more_number) {
|
|
476 |
}
|
477 |
|
478 |
|
479 |
-
|
480 |
// reset instagram request counter to zero for next set of requests
|
481 |
currentFeed.instagramRequestCounter = 0;
|
482 |
|
@@ -487,11 +586,9 @@ wdi_front.displayFeed = function(currentFeed, load_more_number) {
|
|
487 |
wdi_front.updateUsersImages(currentFeed);
|
488 |
|
489 |
|
490 |
-
|
491 |
-
|
492 |
// /**
|
493 |
// * Enable image lazy laoding if pagination is not enabeled because pagination has option for preloading images
|
494 |
-
// * which is the opposide of lazy load
|
495 |
// */
|
496 |
// if( currentFeed.feed_row.feed_display_view != 'pagination' ){
|
497 |
// jQuery(function() {
|
@@ -502,7 +599,7 @@ wdi_front.displayFeed = function(currentFeed, load_more_number) {
|
|
502 |
// });
|
503 |
|
504 |
// }
|
505 |
-
|
506 |
}
|
507 |
|
508 |
/**
|
@@ -510,11 +607,19 @@ wdi_front.displayFeed = function(currentFeed, load_more_number) {
|
|
510 |
* then update source
|
511 |
* @param {Object} currentFeed [description]
|
512 |
*/
|
513 |
-
wdi_front.updateUsersImages = function(currentFeed)
|
|
|
514 |
var elements = jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter).find('.wdi_single_user .wdi_user_img_wrap img');
|
515 |
-
elements.each(function()
|
|
|
516 |
if (jQuery(this).attr('src') == wdi_url.plugin_url + '../images/missing.png' || jQuery(this).attr('src') == '') {
|
517 |
//console.log('missing');
|
|
|
|
|
|
|
|
|
|
|
|
|
518 |
for (var j = 0; j < currentFeed.usersData.length; j++) {
|
519 |
if (currentFeed.usersData[j]['username'] == jQuery(this).parent().parent().find('h3').text()) {
|
520 |
if (currentFeed.usersData[j]['data'].length != 0) {
|
@@ -527,20 +632,21 @@ wdi_front.updateUsersImages = function(currentFeed) {
|
|
527 |
}
|
528 |
|
529 |
|
530 |
-
|
531 |
/**
|
532 |
* Displays data in masonry layout
|
533 |
* @param {Object} data data to be displayed
|
534 |
-
* @param {Object} currentFeed
|
535 |
*/
|
536 |
-
wdi_front.masonryDisplayFeedItems = function(data, currentFeed)
|
|
|
537 |
var masonryColEnds = [];
|
538 |
var masonryColumns = [];
|
539 |
-
if(jQuery('#wdi_feed_'+currentFeed.feed_row.wdi_feed_counter+" .wdi_feed_wrapper").length == 0){
|
540 |
//no feed in DOM, ignore
|
541 |
return;
|
542 |
}
|
543 |
-
jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' .wdi_masonry_column').each(function()
|
|
|
544 |
|
545 |
//if resorte after load more is on then reset columns on every load more
|
546 |
if (currentFeed.feed_row.resort_after_load_more == 1) {
|
@@ -610,7 +716,8 @@ wdi_front.masonryDisplayFeedItems = function(data, currentFeed) {
|
|
610 |
var columnFlag = false;
|
611 |
currentFeed.wdi_load_count = i;
|
612 |
var wdi_feed_counter = currentFeed.feed_row['wdi_feed_counter'];
|
613 |
-
var feed_wrapper = jQuery('#wdi_feed_' + wdi_feed_counter + ' img.wdi_img').on('load', function()
|
|
|
614 |
currentFeed.wdi_loadedImages++;
|
615 |
checkLoaded();
|
616 |
|
@@ -629,15 +736,13 @@ wdi_front.masonryDisplayFeedItems = function(data, currentFeed) {
|
|
629 |
});
|
630 |
|
631 |
|
632 |
-
|
633 |
-
|
634 |
/**
|
635 |
* if feed type is not blog style then after displaying images assign click evetns to their captions
|
636 |
* this part of code is a bit differenet from free version because of image lazy loading feature
|
637 |
-
*
|
638 |
* in free version events are assigned directly in onload event, but when lazy loading added it cased duplicate event fireing
|
639 |
* so event assigning moved to here
|
640 |
-
*
|
641 |
*/
|
642 |
// if ( currentFeed.feed_row.feed_type != 'blog_style' ){
|
643 |
// jQuery('#wdi_feed_'+currentFeed.feed_row.wdi_feed_counter+' .wdi_photo_title').each(function(){
|
@@ -646,10 +751,9 @@ wdi_front.masonryDisplayFeedItems = function(data, currentFeed) {
|
|
646 |
// }
|
647 |
|
648 |
|
649 |
-
|
650 |
-
|
651 |
//checks if all iamges have been succesfully loaded then it updates variables for next time use
|
652 |
-
function checkLoaded()
|
|
|
653 |
|
654 |
if (currentFeed.wdi_load_count === currentFeed.wdi_loadedImages && currentFeed.wdi_loadedImages != 0) {
|
655 |
currentFeed.loadedImages = 0;
|
@@ -671,11 +775,11 @@ wdi_front.masonryDisplayFeedItems = function(data, currentFeed) {
|
|
671 |
}
|
672 |
|
673 |
|
674 |
-
|
675 |
/*
|
676 |
* Calcuates image resolution
|
677 |
*/
|
678 |
-
wdi_front.getImageResolution = function(data)
|
|
|
679 |
|
680 |
var originalWidth = data['images']['standard_resolution']['width'];
|
681 |
var originalHeight = data['images']['standard_resolution']['height'];
|
@@ -687,9 +791,11 @@ wdi_front.getImageResolution = function(data) {
|
|
687 |
* Calculates data count on global Storage and if custom storage provied
|
688 |
* it adds custom storage data count to golbals data count and returns length of all storages
|
689 |
*/
|
690 |
-
wdi_front.getDataLength = function(currentFeed, customStorage)
|
|
|
|
|
691 |
var length = 0;
|
692 |
-
if (customStorage === undefined) {
|
693 |
for (var j = 0; j < currentFeed.dataStorage.length; j++) {
|
694 |
length += currentFeed.dataStorage[j].length;
|
695 |
}
|
@@ -702,7 +808,8 @@ wdi_front.getDataLength = function(currentFeed, customStorage) {
|
|
702 |
return length;
|
703 |
}
|
704 |
|
705 |
-
wdi_front.getArrayContentLength = function(array, data)
|
|
|
706 |
var sum = 0;
|
707 |
for (var i = 0; i < array.length; i++) {
|
708 |
if (array[i]['finished'] == 'finished') {
|
@@ -714,13 +821,13 @@ wdi_front.getArrayContentLength = function(array, data) {
|
|
714 |
}
|
715 |
|
716 |
|
717 |
-
|
718 |
/**
|
719 |
* Displays data in thumbnail layout
|
720 |
* @param {Object} data data to be displayed
|
721 |
-
* @param {Object} currentFeed
|
722 |
*/
|
723 |
-
wdi_front.displayFeedItems = function(data, currentFeed)
|
|
|
724 |
|
725 |
//gets ready data, gets data template, and appens it into feed_wrapper
|
726 |
var wdi_feed_counter = currentFeed.feed_row['wdi_feed_counter'];
|
@@ -754,7 +861,6 @@ wdi_front.displayFeedItems = function(data, currentFeed) {
|
|
754 |
}
|
755 |
|
756 |
|
757 |
-
|
758 |
for (var i = 0; i < data.length; i++) {
|
759 |
if (data[i]['type'] == 'image') {
|
760 |
var photoTemplate = wdi_front.getPhotoTemplate(currentFeed);
|
@@ -785,8 +891,9 @@ wdi_front.displayFeedItems = function(data, currentFeed) {
|
|
785 |
|
786 |
//fixing last row in case of full caption is open
|
787 |
//for that triggering click twice to open and close caption text that will fix last row
|
788 |
-
|
789 |
-
jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' .wdi_feed_wrapper [wdi_index=' + lastIndex + '] .wdi_photo_title').trigger(wdi_front.clickOrTouch);
|
|
|
790 |
|
791 |
|
792 |
//binding onload event for ajax loader
|
@@ -794,7 +901,8 @@ wdi_front.displayFeedItems = function(data, currentFeed) {
|
|
794 |
var columnFlag = false;
|
795 |
currentFeed.wdi_load_count = i;
|
796 |
var wdi_feed_counter = currentFeed.feed_row['wdi_feed_counter'];
|
797 |
-
var feed_wrapper = jQuery('#wdi_feed_' + wdi_feed_counter + ' img.wdi_img').on('load', function()
|
|
|
798 |
currentFeed.wdi_loadedImages++;
|
799 |
checkLoaded();
|
800 |
|
@@ -815,15 +923,13 @@ wdi_front.displayFeedItems = function(data, currentFeed) {
|
|
815 |
});
|
816 |
|
817 |
|
818 |
-
|
819 |
-
|
820 |
/**
|
821 |
* if feed type is not blog style then after displaying images assign click evetns to their captions
|
822 |
* this part of code is a bit differenet from free version because of image lazy loading feature
|
823 |
-
*
|
824 |
* in free version events are assigned directly in onload event, but when lazy loading added it cased duplicate event fireing
|
825 |
* so event assigning moved to here
|
826 |
-
*
|
827 |
*/
|
828 |
// if ( currentFeed.feed_row.feed_type != 'blog_style' ){
|
829 |
// jQuery('#wdi_feed_'+currentFeed.feed_row.wdi_feed_counter+' .wdi_photo_title').each(function(){
|
@@ -833,9 +939,9 @@ wdi_front.displayFeedItems = function(data, currentFeed) {
|
|
833 |
// }
|
834 |
|
835 |
|
836 |
-
|
837 |
//checks if all iamges have been succesfully loaded then it updates variables for next time use
|
838 |
-
function checkLoaded()
|
|
|
839 |
if (currentFeed.wdi_load_count === currentFeed.wdi_loadedImages && currentFeed.wdi_loadedImages != 0) {
|
840 |
currentFeed.loadedImages = 0;
|
841 |
currentFeed.wdi_load_count = 0;
|
@@ -854,86 +960,95 @@ wdi_front.displayFeedItems = function(data, currentFeed) {
|
|
854 |
|
855 |
}
|
856 |
|
857 |
-
wdi_front.checkFeedFinished = function(currentFeed)
|
|
|
858 |
for (var i = 0; i < currentFeed.usersData.length; i++) {
|
859 |
-
if (currentFeed.usersData[i]['finished'] == undefined) {
|
860 |
return false;
|
861 |
}
|
862 |
}
|
863 |
return true;
|
864 |
}
|
865 |
|
866 |
-
wdi_front.sortingOperator = function(sortImagesBy, sortOrder)
|
|
|
867 |
var operator;
|
868 |
switch (sortImagesBy) {
|
869 |
case 'date':
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
|
|
886 |
}
|
887 |
-
break;
|
888 |
}
|
|
|
|
|
889 |
case 'likes':
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
|
|
906 |
}
|
907 |
-
break;
|
908 |
}
|
|
|
|
|
909 |
case 'comments':
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
|
|
926 |
}
|
927 |
-
break;
|
928 |
}
|
|
|
|
|
929 |
case 'random':
|
|
|
|
|
930 |
{
|
931 |
-
|
932 |
-
|
933 |
-
return (num > 0.5) ? 1 : -1;
|
934 |
-
}
|
935 |
-
break;
|
936 |
}
|
|
|
|
|
937 |
}
|
938 |
return operator;
|
939 |
}
|
@@ -941,7 +1056,8 @@ wdi_front.sortingOperator = function(sortImagesBy, sortOrder) {
|
|
941 |
/*
|
942 |
* Calls smart picker method and then after receiving data it sorts data based on user choice
|
943 |
*/
|
944 |
-
wdi_front.feedSort = function(currentFeed, load_more_number)
|
|
|
945 |
|
946 |
var sortImagesBy = currentFeed.feed_row['sort_images_by'];
|
947 |
var sortOrder = currentFeed.feed_row['display_order'];
|
@@ -953,7 +1069,6 @@ wdi_front.feedSort = function(currentFeed, load_more_number) {
|
|
953 |
}
|
954 |
|
955 |
|
956 |
-
|
957 |
var operator = wdi_front.sortingOperator(sortImagesBy, sortOrder);
|
958 |
currentFeed['data'].sort(operator);
|
959 |
return currentFeed['data'];
|
@@ -961,10 +1076,11 @@ wdi_front.feedSort = function(currentFeed, load_more_number) {
|
|
961 |
}
|
962 |
|
963 |
/*
|
964 |
-
* Filters all requested data and takes some amount of
|
965 |
* and stops picking when it reaches number_of_photos limit
|
966 |
*/
|
967 |
-
wdi_front.smartPicker = function(currentFeed, load_more_number)
|
|
|
968 |
|
969 |
var dataStorage = [];
|
970 |
var dataLength = 0;
|
@@ -974,27 +1090,28 @@ wdi_front.smartPicker = function(currentFeed, load_more_number) {
|
|
974 |
var remainder = 0;
|
975 |
|
976 |
//check if loadmore was clicked
|
977 |
-
if (load_more_number != '' && load_more_number != undefined && load_more_number != null) {
|
978 |
number_of_photos = parseInt(load_more_number);
|
979 |
perUser = Math.ceil(number_of_photos / wdi_front.activeUsersCount(currentFeed));
|
980 |
}
|
981 |
|
982 |
|
983 |
-
var sortOperator = function(a, b)
|
|
|
984 |
return (a['data'].length > b['data'].length) ? 1 : -1;
|
985 |
}
|
986 |
|
987 |
-
var sortOperator1 = function(a, b)
|
|
|
988 |
return (a.length() > b.length()) ? 1 : -1;
|
989 |
}
|
990 |
|
991 |
-
|
992 |
|
993 |
// storing user data in global dataStoreageRaw variable
|
994 |
-
currentFeed.storeRawData(
|
995 |
-
|
996 |
//dataStorageRaw
|
997 |
-
var dataStorageRaw = currentFeed['dataStorageRaw'].sort(
|
998 |
|
999 |
//sorts user data desc
|
1000 |
var usersData = currentFeed['usersData'].sort(sortOperator);
|
@@ -1005,109 +1122,100 @@ wdi_front.smartPicker = function(currentFeed, load_more_number) {
|
|
1005 |
for (var i = 0; i < usersData.length; i++) {
|
1006 |
|
1007 |
remainder += perUser;
|
1008 |
-
|
1009 |
/* if data is less then amount for each user then pick all data */
|
1010 |
-
if(
|
1011 |
|
1012 |
/* update remainder */
|
1013 |
remainder -= dataStorageRaw[i].length();
|
1014 |
|
1015 |
/* get and store data */
|
1016 |
-
dataStorage.push(
|
1017 |
/* update data length */
|
1018 |
-
dataLength += dataStorage[
|
1019 |
|
1020 |
|
1021 |
-
}else{
|
1022 |
-
if(
|
1023 |
remainder = number_of_photos - dataLength;
|
1024 |
}
|
1025 |
|
1026 |
var pickedData = [];
|
1027 |
|
1028 |
-
|
1029 |
if (currentFeed['auto_trigger'] === false) {
|
1030 |
-
pickedData = pickedData.concat(
|
1031 |
} else {
|
1032 |
if (pickedData.length + wdi_front.getDataLength(currentFeed) + wdi_front.getDataLength(currentFeed, dataStorage) < currentFeed['feed_row']['number_of_photos']) {
|
1033 |
-
pickedData = pickedData.concat(
|
1034 |
}
|
1035 |
}
|
1036 |
|
1037 |
remainder = 0;
|
1038 |
|
1039 |
dataLength += pickedData.length;
|
1040 |
-
dataStorage.push(
|
1041 |
|
1042 |
|
1043 |
}
|
1044 |
|
1045 |
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
/*if (usersData[i]['data'].length <= remainder) {
|
1056 |
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
}
|
1107 |
-
|
1108 |
//else it simple puches new user with it's data to global storage
|
1109 |
for (i = 0; i < dataStorage.length; i++) {
|
1110 |
-
if (currentFeed.dataStorage[i] === undefined) {
|
1111 |
currentFeed.dataStorage.push(dataStorage[i]);
|
1112 |
} else {
|
1113 |
currentFeed.dataStorage[i] = currentFeed.dataStorage[i].concat(dataStorage[i]);
|
@@ -1128,7 +1236,8 @@ wdi_front.smartPicker = function(currentFeed, load_more_number) {
|
|
1128 |
/*
|
1129 |
* returns json object for inserting photo template
|
1130 |
*/
|
1131 |
-
wdi_front.createObject = function(obj, currentFeed)
|
|
|
1132 |
|
1133 |
var caption = (obj['caption'] != null) ? obj['caption']['text'] : ' ';
|
1134 |
var image_url;
|
@@ -1174,7 +1283,8 @@ wdi_front.createObject = function(obj, currentFeed) {
|
|
1174 |
/*
|
1175 |
* If pagination is on sets the proper page number
|
1176 |
*/
|
1177 |
-
wdi_front.setPage = function(currentFeed)
|
|
|
1178 |
var display_type = currentFeed.feed_row.feed_display_view;
|
1179 |
var feed_type = currentFeed.feed_row.feed_type;
|
1180 |
if (display_type != 'pagination') {
|
@@ -1196,7 +1306,8 @@ wdi_front.setPage = function(currentFeed) {
|
|
1196 |
/*
|
1197 |
* Template for all feed items which have type=image
|
1198 |
*/
|
1199 |
-
wdi_front.getPhotoTemplate = function(currentFeed)
|
|
|
1200 |
var page = wdi_front.setPage(currentFeed);
|
1201 |
var customClass = '';
|
1202 |
var pagination = '';
|
@@ -1210,7 +1321,7 @@ wdi_front.getPhotoTemplate = function(currentFeed) {
|
|
1210 |
if (page != '') {
|
1211 |
pagination = 'wdi_page="' + page + '"';
|
1212 |
sourceAttr = 'src';
|
1213 |
-
}else{
|
1214 |
sourceAttr = 'src';
|
1215 |
}
|
1216 |
|
@@ -1219,9 +1330,7 @@ wdi_front.getPhotoTemplate = function(currentFeed) {
|
|
1219 |
}
|
1220 |
|
1221 |
|
1222 |
-
|
1223 |
-
|
1224 |
-
if(currentFeed.feed_row.show_username_on_thumb == '1'){
|
1225 |
showUsernameOnThumb = '<span class="wdi_media_user">@<%= wdi_username%></span>';
|
1226 |
}
|
1227 |
|
@@ -1232,11 +1341,11 @@ wdi_front.getPhotoTemplate = function(currentFeed) {
|
|
1232 |
}
|
1233 |
|
1234 |
var onclickevent = "";
|
1235 |
-
if(
|
1236 |
-
if(
|
1237 |
-
onclickevent = "wdi_responsive.showMasonryCaption(jQuery(this),"+currentFeed.feed_row.wdi_feed_counter+");"
|
1238 |
-
}else{
|
1239 |
-
onclickevent = "wdi_responsive.showCaption(jQuery(this),"+currentFeed.feed_row.wdi_feed_counter+");";
|
1240 |
}
|
1241 |
|
1242 |
}
|
@@ -1245,30 +1354,30 @@ wdi_front.getPhotoTemplate = function(currentFeed) {
|
|
1245 |
//creating onclick string for different options
|
1246 |
switch (currentFeed.feed_row.feed_item_onclick) {
|
1247 |
case 'lightbox':
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
case 'instagram':
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
case 'none':
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
}
|
1266 |
var wdi_feed_counter = currentFeed.feed_row['wdi_feed_counter'];
|
1267 |
var source = '<div class="wdi_feed_item ' + customClass + '" wdi_index=<%= wdi_index%> wdi_res_index=<%= wdi_res_index%> ' + pagination + ' wdi_type="image" id="wdi_' + wdi_feed_counter + '_<%=id%>">' +
|
1268 |
'<div class="wdi_photo_wrap">' +
|
1269 |
'<div class="wdi_photo_wrap_inner">' +
|
1270 |
'<div class="wdi_photo_img">' +
|
1271 |
-
'<img class="wdi_img" '+sourceAttr+'="<%=image_url%>" alt="feed_image" onerror="wdi_front.brokenImageHandler(this);">' +
|
1272 |
'<div class="wdi_photo_overlay ' + overlayCustomClass + '" >' + showUsernameOnThumb +
|
1273 |
'<div class="wdi_thumb_icon" ' + onclick + ' style="display:table;width:100%;height:100%;">' +
|
1274 |
'<div style="display:table-cell;vertical-align:middle;text-align:center;color:white;">' +
|
@@ -1289,7 +1398,7 @@ wdi_front.getPhotoTemplate = function(currentFeed) {
|
|
1289 |
}
|
1290 |
source += '<div class="clear"></div>';
|
1291 |
if (currentFeed['feed_row']['show_description'] === '1') {
|
1292 |
-
source += '<div class="wdi_photo_title" onclick='+ onclickevent +' >' +
|
1293 |
'<%=caption%>' +
|
1294 |
'</div>';
|
1295 |
}
|
@@ -1301,7 +1410,8 @@ wdi_front.getPhotoTemplate = function(currentFeed) {
|
|
1301 |
return template;
|
1302 |
}
|
1303 |
|
1304 |
-
wdi_front.replaceToVideo = function(url, index, feed_counter)
|
|
|
1305 |
|
1306 |
overlayHtml = "<video style='width:auto !important; height:auto !important; max-width:100% !important; max-height:100% !important; margin:0 !important;' controls=''>" +
|
1307 |
"<source src='" + url + "' type='video/mp4'>" +
|
@@ -1314,7 +1424,8 @@ wdi_front.replaceToVideo = function(url, index, feed_counter) {
|
|
1314 |
/*
|
1315 |
* Template for all feed items which have type=video
|
1316 |
*/
|
1317 |
-
wdi_front.getVideoTemplate = function(currentFeed)
|
|
|
1318 |
var page = wdi_front.setPage(currentFeed);
|
1319 |
var customClass = '';
|
1320 |
var pagination = '';
|
@@ -1328,14 +1439,14 @@ wdi_front.getVideoTemplate = function(currentFeed) {
|
|
1328 |
if (page != '') {
|
1329 |
pagination = 'wdi_page="' + page + '"';
|
1330 |
sourceAttr = 'src';
|
1331 |
-
}else{
|
1332 |
sourceAttr = 'src';
|
1333 |
}
|
1334 |
if (page != '' && page != 1) {
|
1335 |
customClass = 'wdi_hidden';
|
1336 |
}
|
1337 |
|
1338 |
-
if(currentFeed.feed_row.show_username_on_thumb == '1'){
|
1339 |
showUsernameOnThumb = '<span class="wdi_media_user">@<%= wdi_username%></span>';
|
1340 |
}
|
1341 |
|
@@ -1346,11 +1457,11 @@ wdi_front.getVideoTemplate = function(currentFeed) {
|
|
1346 |
}
|
1347 |
|
1348 |
var onclickevent = "";
|
1349 |
-
if(
|
1350 |
-
if(
|
1351 |
-
onclickevent = "wdi_responsive.showMasonryCaption(jQuery(this),"+currentFeed.feed_row.wdi_feed_counter+");"
|
1352 |
-
}else{
|
1353 |
-
onclickevent = "wdi_responsive.showCaption(jQuery(this),"+currentFeed.feed_row.wdi_feed_counter+");";
|
1354 |
}
|
1355 |
|
1356 |
}
|
@@ -1358,27 +1469,27 @@ wdi_front.getVideoTemplate = function(currentFeed) {
|
|
1358 |
//creating onclick string for different options
|
1359 |
switch (currentFeed.feed_row.feed_item_onclick) {
|
1360 |
case 'lightbox':
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
case 'instagram':
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
case 'none':
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
}
|
1381 |
}
|
|
|
1382 |
}
|
1383 |
|
1384 |
|
@@ -1387,8 +1498,8 @@ wdi_front.getVideoTemplate = function(currentFeed) {
|
|
1387 |
'<div class="wdi_photo_wrap">' +
|
1388 |
'<div class="wdi_photo_wrap_inner">' +
|
1389 |
'<div class="wdi_photo_img">' +
|
1390 |
-
'<img class="wdi_img" '+sourceAttr+'="<%=image_url%>" alt="feed_image" onerror="wdi_front.brokenImageHandler(this);">' +
|
1391 |
-
'<div class="wdi_photo_overlay ' + overlayCustomClass + '" ' + onclick + '>' +
|
1392 |
'<div class="wdi_thumb_icon" style="display:table;width:100%;height:100%;">' +
|
1393 |
'<div style="display:table-cell;vertical-align:middle;text-align:center;color:white;">' +
|
1394 |
'<i class="fa ' + thumbClass + '"></i>' +
|
@@ -1408,7 +1519,7 @@ wdi_front.getVideoTemplate = function(currentFeed) {
|
|
1408 |
}
|
1409 |
source += '<div class="clear"></div>';
|
1410 |
if (currentFeed['feed_row']['show_description'] === '1') {
|
1411 |
-
source += '<div class="wdi_photo_title" onclick='+ onclickevent +' >' +
|
1412 |
'<%=caption%>' +
|
1413 |
'</div>';
|
1414 |
}
|
@@ -1419,28 +1530,34 @@ wdi_front.getVideoTemplate = function(currentFeed) {
|
|
1419 |
return template;
|
1420 |
}
|
1421 |
|
1422 |
-
wdi_front.bindEvents = function(currentFeed)
|
|
|
1423 |
if (currentFeed.feed_row.feed_display_view == 'load_more_btn') {
|
1424 |
//binding load more event
|
1425 |
-
jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' .wdi_load_more_container').on(wdi_front.clickOrTouch, function()
|
|
|
1426 |
//do the actual load more operation
|
1427 |
wdi_front.loadMore(jQuery(this).find('.wdi_load_more_wrap'));
|
1428 |
-
|
1429 |
});
|
1430 |
}
|
1431 |
|
1432 |
if (currentFeed.feed_row.feed_display_view == 'pagination') {
|
1433 |
//binding pagination events
|
1434 |
-
jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_next').on(wdi_front.clickOrTouch, function()
|
|
|
1435 |
wdi_front.paginatorNext(jQuery(this), currentFeed);
|
1436 |
});
|
1437 |
-
jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_prev').on(wdi_front.clickOrTouch, function()
|
|
|
1438 |
wdi_front.paginatorPrev(jQuery(this), currentFeed);
|
1439 |
});
|
1440 |
-
jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_last_page').on(wdi_front.clickOrTouch, function()
|
|
|
1441 |
wdi_front.paginationLastPage(jQuery(this), currentFeed);
|
1442 |
});
|
1443 |
-
jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_first_page').on(wdi_front.clickOrTouch, function()
|
|
|
1444 |
wdi_front.paginationFirstPage(jQuery(this), currentFeed);
|
1445 |
});
|
1446 |
//setting pagiantion flags
|
@@ -1448,7 +1565,8 @@ wdi_front.bindEvents = function(currentFeed) {
|
|
1448 |
}
|
1449 |
if (currentFeed.feed_row.feed_display_view == 'infinite_scroll') {
|
1450 |
//binding infinite scroll Events
|
1451 |
-
jQuery(window).on('scroll', function()
|
|
|
1452 |
wdi_front.infiniteScroll(currentFeed);
|
1453 |
});
|
1454 |
//infinite scroll flags
|
@@ -1458,22 +1576,24 @@ wdi_front.bindEvents = function(currentFeed) {
|
|
1458 |
|
1459 |
}
|
1460 |
|
1461 |
-
wdi_front.infiniteScroll = function(currentFeed)
|
|
|
1462 |
|
1463 |
if (jQuery(window).scrollTop() <= jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_infinite_scroll').offset().top) {
|
1464 |
if (currentFeed.infiniteScrollFlag === false && currentFeed.stopInfiniteScrollFlag == false) {
|
1465 |
currentFeed.infiniteScrollFlag = true;
|
1466 |
wdi_front.loadMore(jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_infinite_scroll'), currentFeed);
|
1467 |
-
} else
|
1468 |
-
|
1469 |
-
|
|
|
1470 |
|
1471 |
}
|
1472 |
}
|
1473 |
|
1474 |
|
1475 |
-
|
1476 |
-
|
1477 |
if (currentFeed.paginator == 1 || currentFeed.currentPage == 1) {
|
1478 |
btn.addClass('wdi_disabled');
|
1479 |
return;
|
@@ -1491,7 +1611,8 @@ wdi_front.paginationFirstPage = function(btn, currentFeed) {
|
|
1491 |
|
1492 |
}
|
1493 |
|
1494 |
-
wdi_front.paginationLastPage = function(btn, currentFeed)
|
|
|
1495 |
if (currentFeed.paginator == 1 || currentFeed.currentPage == currentFeed.paginator) {
|
1496 |
return;
|
1497 |
}
|
@@ -1507,8 +1628,8 @@ wdi_front.paginationLastPage = function(btn, currentFeed) {
|
|
1507 |
first_page_btn.removeClass('wdi_disabled');
|
1508 |
}
|
1509 |
|
1510 |
-
wdi_front.paginatorNext = function(btn, currentFeed)
|
1511 |
-
|
1512 |
var last_page_btn = btn.parent().find('#wdi_last_page');
|
1513 |
var first_page_btn = btn.parent().find('#wdi_first_page');
|
1514 |
currentFeed.paginatorNextFlag = true;
|
@@ -1518,16 +1639,17 @@ wdi_front.paginatorNext = function(btn, currentFeed) {
|
|
1518 |
wdi_front.loadMore(btn, currentFeed, number_of_photos);
|
1519 |
//on the last page don't show got to last page button
|
1520 |
last_page_btn.addClass('wdi_disabled');
|
1521 |
-
} else
|
1522 |
-
currentFeed.currentPage++;
|
1523 |
-
wdi_front.updatePagination(currentFeed, 'next');
|
1524 |
-
//check if new page isn't the last one then enable last page button
|
1525 |
if (currentFeed.paginator > currentFeed.currentPage) {
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
|
|
|
|
|
|
|
|
|
|
1529 |
}
|
1530 |
-
}
|
1531 |
|
1532 |
//enable first page button
|
1533 |
first_page_btn.removeClass('wdi_disabled');
|
@@ -1535,7 +1657,8 @@ wdi_front.paginatorNext = function(btn, currentFeed) {
|
|
1535 |
|
1536 |
}
|
1537 |
|
1538 |
-
wdi_front.paginatorPrev = function(btn, currentFeed)
|
|
|
1539 |
var last_page_btn = btn.parent().find('#wdi_last_page');
|
1540 |
var first_page_btn = btn.parent().find('#wdi_first_page');
|
1541 |
if (currentFeed.currentPage == 1) {
|
@@ -1556,42 +1679,47 @@ wdi_front.paginatorPrev = function(btn, currentFeed) {
|
|
1556 |
}
|
1557 |
|
1558 |
//displays proper images for specific page after pagination buttons click event
|
1559 |
-
wdi_front.updatePagination = function(currentFeed, dir, oldPage)
|
|
|
1560 |
var currentFeedString = '#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'];
|
1561 |
-
jQuery(currentFeedString + ' [wdi_page="' + currentFeed.currentPage + '"]').each(function()
|
|
|
1562 |
jQuery(this).removeClass('wdi_hidden');
|
1563 |
});
|
1564 |
switch (dir) {
|
1565 |
case 'next':
|
|
|
|
|
|
|
|
|
1566 |
{
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
});
|
1572 |
-
break;
|
1573 |
-
}
|
1574 |
case 'prev':
|
|
|
|
|
|
|
|
|
1575 |
{
|
1576 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1577 |
jQuery(currentFeedString + ' .wdi_feed_wrapper').height(jQuery('.wdi_feed_wrapper').height());
|
1578 |
-
jQuery(currentFeedString + ' [wdi_page="' + oldPage + '"]').each(function()
|
|
|
1579 |
jQuery(this).addClass('wdi_hidden');
|
1580 |
});
|
1581 |
-
break;
|
1582 |
}
|
1583 |
-
case 'custom':
|
1584 |
-
{
|
1585 |
-
var oldPage = oldPage;
|
1586 |
-
if (oldPage != currentFeed.currentPage) {
|
1587 |
-
jQuery(currentFeedString + ' .wdi_feed_wrapper').height(jQuery('.wdi_feed_wrapper').height());
|
1588 |
-
jQuery(currentFeedString + ' [wdi_page="' + oldPage + '"]').each(function() {
|
1589 |
-
jQuery(this).addClass('wdi_hidden');
|
1590 |
-
});
|
1591 |
-
}
|
1592 |
|
1593 |
-
|
1594 |
-
|
1595 |
}
|
1596 |
currentFeed.paginatorNextFlag = false;
|
1597 |
|
@@ -1600,14 +1728,15 @@ wdi_front.updatePagination = function(currentFeed, dir, oldPage) {
|
|
1600 |
}
|
1601 |
|
1602 |
|
1603 |
-
wdi_front.loadMore = function(button, _currentFeed)
|
|
|
1604 |
|
1605 |
|
1606 |
var dataCounter = 0;
|
1607 |
-
if (button != '' && button != undefined && button != 'initial' && button != 'initial-keep') {
|
1608 |
var currentFeed = window[button.parent().parent().parent().parent().attr('id')];
|
1609 |
}
|
1610 |
-
if (_currentFeed != undefined) {
|
1611 |
var currentFeed = _currentFeed;
|
1612 |
}
|
1613 |
//check if any filter is enabled and filter user images has finished
|
@@ -1637,21 +1766,20 @@ wdi_front.loadMore = function(button, _currentFeed) {
|
|
1637 |
} else {
|
1638 |
currentFeed['auto_trigger'] = false;
|
1639 |
}
|
1640 |
-
//ading ajax loading
|
1641 |
wdi_front.ajaxLoader(currentFeed);
|
1642 |
|
1643 |
|
1644 |
-
|
1645 |
//check if masonry view is on and and feed display type is pagination then
|
1646 |
//close all captions before loading more pages for porper pagination rendering
|
1647 |
if (currentFeed.feed_row.feed_type === 'masonry' && currentFeed.feed_row.feed_display_view == 'pagination') {
|
1648 |
-
jQuery('#wdi_feed_' + wdi_front.feed_counter + ' .wdi_full_caption').each(function()
|
|
|
1649 |
jQuery(this).find('.wdi_photo_title').trigger(wdi_front.clickOrTouch);
|
1650 |
});
|
1651 |
}
|
1652 |
|
1653 |
|
1654 |
-
|
1655 |
//check if all data loaded then remove ajaxLoader
|
1656 |
for (var i = 0; i < currentFeed.usersData.length; i++) {
|
1657 |
if (currentFeed.usersData[i]['finished'] === 'finished') {
|
@@ -1672,26 +1800,23 @@ wdi_front.loadMore = function(button, _currentFeed) {
|
|
1672 |
|
1673 |
var pagination = usersData[i]['pagination'];
|
1674 |
var user = {
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
//checking if pagination url exists then load images, else skip
|
1680 |
-
if (pagination['next_url'] != '' && pagination['next_url'] != null && pagination['next_url'] != undefined) {
|
1681 |
var next_url = pagination['next_url'];
|
1682 |
wdi_front.loadMoreRequest(user, next_url, currentFeed, button);
|
1683 |
} else {
|
1684 |
|
1685 |
if (button == 'initial-keep') {
|
1686 |
-
|
1687 |
currentFeed.temproraryUsersData[i] = currentFeed.usersData[i];
|
1688 |
}
|
1689 |
currentFeed.loadMoreDataCount--;
|
1690 |
|
1691 |
-
|
1692 |
-
wdi_front.checkForLoadMoreDone(currentFeed, button);
|
1693 |
-
|
1694 |
|
|
|
1695 |
continue;
|
1696 |
}
|
1697 |
}
|
@@ -1702,16 +1827,16 @@ wdi_front.loadMore = function(button, _currentFeed) {
|
|
1702 |
/*
|
1703 |
* Requests images based on provided pagination url
|
1704 |
*/
|
1705 |
-
wdi_front.loadMoreRequest = function(user, next_url, currentFeed, button)
|
|
|
1706 |
|
1707 |
var usersData = currentFeed['usersData'];
|
1708 |
var errorMessage = '';
|
1709 |
|
1710 |
-
|
1711 |
currentFeed.instagram.requestByUrl(next_url, {
|
1712 |
-
success: function(response)
|
1713 |
-
|
1714 |
-
if (response === '' || response == undefined || response == null) {
|
1715 |
errorMessage = wdi_front_messages.network_error;
|
1716 |
currentFeed.loadMoreDataCount--;
|
1717 |
alert(errorMessage);
|
@@ -1736,10 +1861,11 @@ wdi_front.loadMoreRequest = function(user, next_url, currentFeed, button) {
|
|
1736 |
}
|
1737 |
////////////////
|
1738 |
/*if button is initial-keep then we will lose currentFeed['usersData'][i]
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
|
|
1743 |
if (button == 'initial-keep') {
|
1744 |
currentFeed.temproraryUsersData[i] = currentFeed.usersData[i];
|
1745 |
}
|
@@ -1756,7 +1882,8 @@ wdi_front.loadMoreRequest = function(user, next_url, currentFeed, button) {
|
|
1756 |
|
1757 |
}
|
1758 |
|
1759 |
-
wdi_front.checkForLoadMoreDone = function(currentFeed, button)
|
|
|
1760 |
var load_more_number = currentFeed.feed_row['load_more_number'];
|
1761 |
var number_of_photos = currentFeed.feed_row['number_of_photos'];
|
1762 |
|
@@ -1764,16 +1891,16 @@ wdi_front.checkForLoadMoreDone = function(currentFeed, button) {
|
|
1764 |
|
1765 |
currentFeed.temproraryUsersData = wdi_front.mergeData(currentFeed.temproraryUsersData, currentFeed.usersData);
|
1766 |
var gettedDataLength = wdi_front.getArrayContentLength(currentFeed.temproraryUsersData, 'data');
|
1767 |
-
/*this will happen when we call loadMore first time
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
if (button == 'initial-keep') {
|
1772 |
button = 'initial';
|
1773 |
}
|
1774 |
//if button is set to inital load number_of_photos photos
|
1775 |
if (button == 'initial') {
|
1776 |
-
|
1777 |
/*if existing data length is smaller then load_more_number then get more objects until desired number is reached
|
1778 |
also if it is not possible to reach the desired number (this will happen when all users has no more photos) then
|
1779 |
displayFeed()*/
|
@@ -1784,7 +1911,7 @@ wdi_front.checkForLoadMoreDone = function(currentFeed, button) {
|
|
1784 |
} else {
|
1785 |
|
1786 |
currentFeed.usersData = currentFeed.temproraryUsersData;
|
1787 |
-
|
1788 |
wdi_front.displayFeed(currentFeed);
|
1789 |
//when all data us properly displayed check for any active filters and then apply them
|
1790 |
wdi_front.applyFilters(currentFeed);
|
@@ -1792,7 +1919,7 @@ wdi_front.checkForLoadMoreDone = function(currentFeed, button) {
|
|
1792 |
//resetting temprorary users data array for the next loadmoer call
|
1793 |
currentFeed.temproraryUsersData = [];
|
1794 |
|
1795 |
-
|
1796 |
}
|
1797 |
|
1798 |
} else {
|
@@ -1806,11 +1933,10 @@ wdi_front.checkForLoadMoreDone = function(currentFeed, button) {
|
|
1806 |
|
1807 |
currentFeed.usersData = currentFeed.temproraryUsersData;
|
1808 |
|
1809 |
-
if(
|
1810 |
return;
|
1811 |
-
}
|
1812 |
|
1813 |
-
//debugger;
|
1814 |
wdi_front.displayFeed(currentFeed, load_more_number);
|
1815 |
//when all data us properly displayed check for any active filters and then apply them
|
1816 |
wdi_front.applyFilters(currentFeed);
|
@@ -1821,14 +1947,14 @@ wdi_front.checkForLoadMoreDone = function(currentFeed, button) {
|
|
1821 |
}
|
1822 |
|
1823 |
|
1824 |
-
|
1825 |
}
|
1826 |
}
|
1827 |
|
1828 |
-
wdi_front.allDataHasFinished = function(
|
|
|
1829 |
var c = 0;
|
1830 |
-
for(
|
1831 |
-
if(
|
1832 |
c++;
|
1833 |
}
|
1834 |
}
|
@@ -1837,16 +1963,19 @@ wdi_front.allDataHasFinished = function( currentFeed ){
|
|
1837 |
}
|
1838 |
|
1839 |
|
1840 |
-
wdi_front.mergeData = function(array1, array2)
|
|
|
1841 |
|
1842 |
|
1843 |
for (var i = 0; i < array2.length; i++) {
|
1844 |
-
if (array1[i] != undefined) {
|
1845 |
if (array2[i]['finished'] == 'finished') {
|
1846 |
continue;
|
1847 |
}
|
|
|
1848 |
//if user data is finished then dont add duplicate data
|
1849 |
-
if (array1[i]['pagination']['next_max_id'] == undefined
|
|
|
1850 |
continue;
|
1851 |
}
|
1852 |
//extend data
|
@@ -1863,9 +1992,9 @@ wdi_front.mergeData = function(array1, array2) {
|
|
1863 |
}
|
1864 |
|
1865 |
|
1866 |
-
|
1867 |
//broken image handling
|
1868 |
-
wdi_front.brokenImageHandler = function(source)
|
|
|
1869 |
source.src = wdi_url.plugin_url + "../images/missing.png";
|
1870 |
source.onerror = "";
|
1871 |
return true;
|
@@ -1874,7 +2003,8 @@ wdi_front.brokenImageHandler = function(source) {
|
|
1874 |
|
1875 |
|
1876 |
//ajax loading
|
1877 |
-
wdi_front.ajaxLoader = function(currentFeed)
|
|
|
1878 |
var wdi_feed_counter = currentFeed.feed_row['wdi_feed_counter'];
|
1879 |
|
1880 |
var feed_container = jQuery('#wdi_feed_' + wdi_feed_counter);
|
@@ -1895,13 +2025,13 @@ wdi_front.ajaxLoader = function(currentFeed) {
|
|
1895 |
}
|
1896 |
|
1897 |
|
1898 |
-
|
1899 |
////////////////////////////////////////////////////
|
1900 |
|
1901 |
}
|
1902 |
|
1903 |
//if all images loaded then clicking load more causes it's removal
|
1904 |
-
wdi_front.allImagesLoaded = function(currentFeed)
|
|
|
1905 |
////////////////////////////////////////////////////////////////////
|
1906 |
|
1907 |
//clearInterval(currentFeed.loadingInterval);
|
@@ -1924,8 +2054,6 @@ wdi_front.allImagesLoaded = function(currentFeed) {
|
|
1924 |
}
|
1925 |
|
1926 |
|
1927 |
-
|
1928 |
-
|
1929 |
//custom event fired for user based custom js
|
1930 |
feed_container.trigger('wdi_feed_loaded');
|
1931 |
|
@@ -1934,25 +2062,27 @@ wdi_front.allImagesLoaded = function(currentFeed) {
|
|
1934 |
|
1935 |
|
1936 |
//shows different parts of the feed based user choice
|
1937 |
-
wdi_front.show = function(name, currentFeed)
|
|
|
1938 |
var wdi_feed_counter = currentFeed.feed_row['wdi_feed_counter'];
|
1939 |
var feed_container = jQuery('#wdi_feed_' + wdi_feed_counter + ' .wdi_feed_container');
|
1940 |
var _this = this;
|
1941 |
switch (name) {
|
1942 |
case 'header':
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
case 'users':
|
1948 |
-
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
|
1953 |
}
|
1954 |
|
1955 |
-
function show_header()
|
|
|
1956 |
|
1957 |
var templateData = {
|
1958 |
'feed_thumb': currentFeed['feed_row']['feed_thumb'],
|
@@ -1966,10 +2096,10 @@ wdi_front.show = function(name, currentFeed) {
|
|
1966 |
feed_container.find('.wdi_feed_header').html(containerHtml + html);
|
1967 |
|
1968 |
|
1969 |
-
|
1970 |
}
|
1971 |
|
1972 |
-
function show_users(currentFeed)
|
|
|
1973 |
feed_container.find('.wdi_feed_users').html('');
|
1974 |
var users = currentFeed['feed_users'];
|
1975 |
var access_token = currentFeed['feed_row']['access_token'];
|
@@ -1977,46 +2107,73 @@ wdi_front.show = function(name, currentFeed) {
|
|
1977 |
currentFeed.headerUserinfo = [];
|
1978 |
getThumb();
|
1979 |
//recursively calls itself until all user data is ready then displyes it with escapeRequest
|
1980 |
-
function getThumb()
|
|
|
1981 |
|
1982 |
if (currentFeed.headerUserinfo.length == users.length) {
|
1983 |
escapeRequest(currentFeed.headerUserinfo, currentFeed);
|
1984 |
return;
|
1985 |
}
|
1986 |
var _user = users[currentFeed.headerUserinfo.length];
|
1987 |
-
|
1988 |
-
|
|
|
|
|
|
|
1989 |
{
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1995 |
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
}
|
2001 |
-
var obj = {
|
2002 |
-
name: users[i]['username'],
|
2003 |
-
url: thumb_img,
|
2004 |
-
};
|
2005 |
-
i++;
|
2006 |
-
currentFeed.headerUserinfo.push(obj);
|
2007 |
-
getThumb();
|
2008 |
}
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
|
|
|
|
|
|
|
|
2012 |
}
|
2013 |
-
}
|
2014 |
-
|
2015 |
-
|
2016 |
-
|
2017 |
-
|
|
|
|
|
|
|
2018 |
currentFeed.instagram.getUserInfo(_user.id, {
|
2019 |
-
success: function(response)
|
|
|
2020 |
response = _this.checkMediaResponse(response);
|
2021 |
if (response != false) {
|
2022 |
var obj = {
|
@@ -2033,16 +2190,17 @@ wdi_front.show = function(name, currentFeed) {
|
|
2033 |
getThumb();
|
2034 |
}
|
2035 |
},
|
2036 |
-
args
|
2037 |
-
ignoreFiltering
|
2038 |
}
|
2039 |
-
})
|
2040 |
-
break;
|
2041 |
}
|
2042 |
-
|
2043 |
}
|
|
|
2044 |
//when all user data is ready break recursion and create user elements
|
2045 |
-
function escapeRequest(info, currentFeed)
|
|
|
2046 |
feed_container.find('.wdi_feed_users').html('');
|
2047 |
for (var k = 0; k < info.length; k++) {
|
2048 |
//setting all user filters to false
|
@@ -2076,7 +2234,6 @@ wdi_front.show = function(name, currentFeed) {
|
|
2076 |
feed_container.find('.wdi_feed_users').html(containerHtml + html);
|
2077 |
|
2078 |
|
2079 |
-
|
2080 |
currentFeed.userSortFlags.push(userFilter);
|
2081 |
|
2082 |
var clearFloat = jQuery('<div class="clear"></div>');
|
@@ -2090,21 +2247,23 @@ wdi_front.show = function(name, currentFeed) {
|
|
2090 |
}
|
2091 |
|
2092 |
|
2093 |
-
wdi_front.getUserTemplate = function(currentFeed, username)
|
|
|
|
|
2094 |
var usersCount = currentFeed.feed_row.feed_users.split(',').length,
|
2095 |
instagramLink, instagramLinkOnClick, js;
|
2096 |
|
2097 |
switch (username[0]) {
|
2098 |
case '#':
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
|
2103 |
default:
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
}
|
2109 |
js = 'window.open("' + instagramLink + '","_blank")';
|
2110 |
instagramLinkOnClick = "onclick='" + js + "'";
|
@@ -2145,19 +2304,20 @@ wdi_front.getUserTemplate = function(currentFeed, username) {
|
|
2145 |
|
2146 |
if (usersCount == 1 && username[0] !== '#' && currentFeed.feed_row.display_user_info == '1') {
|
2147 |
source += '<div class="wdi_bio"><%= bio%></div>';
|
2148 |
-
}
|
2149 |
|
|
|
2150 |
|
2151 |
|
2152 |
source += '</div>' +
|
2153 |
'</div>';
|
|
|
2154 |
var template = _.template(source);
|
2155 |
return template;
|
2156 |
}
|
2157 |
|
2158 |
|
2159 |
-
|
2160 |
-
|
2161 |
var source = '<div class="wdi_header_wrapper">' +
|
2162 |
'<div class="wdi_header_img_wrap">' +
|
2163 |
'<img src="<%=feed_thumb%>">' +
|
@@ -2171,7 +2331,8 @@ wdi_front.getHeaderTemplate = function() {
|
|
2171 |
|
2172 |
|
2173 |
//sets user filter to true and applys filter to feed
|
2174 |
-
wdi_front.addFilter = function(index, feed_counter)
|
|
|
2175 |
var currentFeed = window['wdi_feed_' + feed_counter];
|
2176 |
var usersCount = currentFeed.feed_row.feed_users.split(',').length;
|
2177 |
if (usersCount < 2) {
|
@@ -2204,7 +2365,6 @@ wdi_front.addFilter = function(index, feed_counter) {
|
|
2204 |
}
|
2205 |
|
2206 |
|
2207 |
-
|
2208 |
if (currentFeed.feed_row.feed_display_view == 'pagination') {
|
2209 |
//reset responsive indexes because number of feed images may change after using filter
|
2210 |
currentFeed.resIndex = 0;
|
@@ -2236,7 +2396,8 @@ wdi_front.addFilter = function(index, feed_counter) {
|
|
2236 |
}
|
2237 |
}
|
2238 |
|
2239 |
-
wdi_front.filterData = function(currentFeed)
|
|
|
2240 |
|
2241 |
var users = currentFeed.userSortFlags;
|
2242 |
currentFeed.customFilteredData = [];
|
@@ -2251,7 +2412,8 @@ wdi_front.filterData = function(currentFeed) {
|
|
2251 |
|
2252 |
}
|
2253 |
|
2254 |
-
wdi_front.applyFilters = function(currentFeed)
|
|
|
2255 |
for (var i = 0; i < currentFeed.userSortFlags.length; i++) {
|
2256 |
if (currentFeed.userSortFlags[i]['flag'] == true) {
|
2257 |
var userDiv = jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + '[user_index="' + i + '"]');
|
@@ -2263,7 +2425,8 @@ wdi_front.applyFilters = function(currentFeed) {
|
|
2263 |
}
|
2264 |
|
2265 |
//gets data Count from global storage
|
2266 |
-
wdi_front.getImgCount = function(currentFeed)
|
|
|
2267 |
var dataStorage = currentFeed.dataStorage;
|
2268 |
var count = 0;
|
2269 |
for (var i = 0; i < dataStorage.length; i++) {
|
@@ -2273,7 +2436,8 @@ wdi_front.getImgCount = function(currentFeed) {
|
|
2273 |
}
|
2274 |
|
2275 |
//parses image data for lightbox popup
|
2276 |
-
wdi_front.parseLighboxData = function(currentFeed, filterFlag)
|
|
|
2277 |
|
2278 |
var dataStorage = currentFeed.dataStorage;
|
2279 |
var sortImagesBy = currentFeed.feed_row['sort_images_by'];
|
@@ -2298,7 +2462,6 @@ wdi_front.parseLighboxData = function(currentFeed, filterFlag) {
|
|
2298 |
}
|
2299 |
|
2300 |
|
2301 |
-
|
2302 |
for (i = 0; i < data.length; i++) {
|
2303 |
obj = {
|
2304 |
'alt': '',
|
@@ -2324,7 +2487,8 @@ wdi_front.parseLighboxData = function(currentFeed, filterFlag) {
|
|
2324 |
return popupData;
|
2325 |
}
|
2326 |
|
2327 |
-
wdi_front.convertUnixDate = function(date)
|
|
|
2328 |
var utcSeconds = parseInt(date);
|
2329 |
var newDate = new Date(0);
|
2330 |
newDate.setUTCSeconds(utcSeconds);
|
@@ -2333,14 +2497,16 @@ wdi_front.convertUnixDate = function(date) {
|
|
2333 |
return str;
|
2334 |
}
|
2335 |
|
2336 |
-
wdi_front.getDescription = function(desc)
|
|
|
2337 |
desc = desc.replace(/\r?\n|\r/g, ' ');
|
2338 |
|
2339 |
|
2340 |
return desc;
|
2341 |
}
|
2342 |
|
2343 |
-
wdi_front.getFileName = function(data)
|
|
|
2344 |
var link = data['link'];
|
2345 |
var type = data['type'];
|
2346 |
if (type === 'image') {
|
@@ -2352,7 +2518,8 @@ wdi_front.getFileName = function(data) {
|
|
2352 |
|
2353 |
}
|
2354 |
|
2355 |
-
wdi_front.getFileType = function(type)
|
|
|
2356 |
if (type === 'image') {
|
2357 |
return "EMBED_OEMBED_INSTAGRAM_IMAGE";
|
2358 |
}
|
@@ -2362,8 +2529,8 @@ wdi_front.getFileType = function(type) {
|
|
2362 |
}
|
2363 |
|
2364 |
|
2365 |
-
|
2366 |
-
|
2367 |
var max = array[0];
|
2368 |
var minIndex = 0;
|
2369 |
for (var i = 1; i < array.length; i++) {
|
@@ -2378,7 +2545,8 @@ wdi_front.array_max = function(array) {
|
|
2378 |
};
|
2379 |
}
|
2380 |
|
2381 |
-
wdi_front.array_min = function(array)
|
|
|
2382 |
var min = array[0];
|
2383 |
var minIndex = 0;
|
2384 |
for (var i = 1; i < array.length; i++) {
|
@@ -2396,7 +2564,8 @@ wdi_front.array_min = function(array) {
|
|
2396 |
/*
|
2397 |
* Returns users count whose feed is not finished
|
2398 |
*/
|
2399 |
-
wdi_front.activeUsersCount = function(currentFeed)
|
|
|
2400 |
var counter = 0;
|
2401 |
for (var i = 0; i < currentFeed.usersData.length; i++) {
|
2402 |
if (currentFeed.usersData[i].finished != 'finished') {
|
@@ -2407,15 +2576,15 @@ wdi_front.activeUsersCount = function(currentFeed) {
|
|
2407 |
}
|
2408 |
|
2409 |
|
2410 |
-
|
2411 |
/**
|
2412 |
* Return response if it is valid else returns boolean false
|
2413 |
* @param {Object} response [instagram API response]
|
2414 |
* @return {Object or Boolean} [false: if invalid response, object: if valid]
|
2415 |
*/
|
2416 |
-
wdi_front.checkMediaResponse = function(response)
|
|
|
2417 |
|
2418 |
-
if (response == '' || response == undefined || response == null) {
|
2419 |
errorMessage = wdi_front_messages.connection_error;
|
2420 |
alert(errorMessage);
|
2421 |
return false;
|
@@ -2434,18 +2603,19 @@ wdi_front.checkMediaResponse = function(response) {
|
|
2434 |
* @param {String} hashtag
|
2435 |
* @return {String}
|
2436 |
*/
|
2437 |
-
wdi_front.stripHashtag = function(hashtag)
|
|
|
2438 |
switch (hashtag[0]) {
|
2439 |
case '#':
|
2440 |
-
|
2441 |
-
|
2442 |
-
|
2443 |
-
|
2444 |
default:
|
2445 |
-
|
2446 |
-
|
2447 |
-
|
2448 |
-
|
2449 |
}
|
2450 |
}
|
2451 |
|
@@ -2454,23 +2624,25 @@ wdi_front.stripHashtag = function(hashtag) {
|
|
2454 |
* @param {String} input [this is username or hashtag]
|
2455 |
* @return {String} [input type]
|
2456 |
*/
|
2457 |
-
wdi_front.getInputType = function(input)
|
|
|
|
|
2458 |
switch (input[0]) {
|
2459 |
case '#':
|
2460 |
-
|
2461 |
-
|
2462 |
-
|
2463 |
-
|
2464 |
case '%':
|
2465 |
-
|
2466 |
-
|
2467 |
-
|
2468 |
-
|
2469 |
default:
|
2470 |
-
|
2471 |
-
|
2472 |
-
|
2473 |
-
|
2474 |
|
2475 |
}
|
2476 |
}
|
@@ -2480,65 +2652,66 @@ wdi_front.getInputType = function(input) {
|
|
2480 |
* or word is in the beggining or in the end of string
|
2481 |
* @param {String} captionText [String where search needs to be done]
|
2482 |
* @param {String} searchkey [word or phrazee to search]
|
2483 |
-
* @return {Boolean}
|
2484 |
*/
|
2485 |
-
wdi_front.regexpTestCaption = function(
|
|
|
2486 |
var flag1 = false,
|
2487 |
flag2 = false,
|
2488 |
matchIndexes = [],
|
2489 |
escKey = searchkey.replace(/[-[\]{}()*+?.,\\^$|]/g, "\\$&"),
|
2490 |
-
regexp1 = new RegExp("(?:^|\\s)"+escKey+"(?:^|\\s)"),
|
2491 |
-
regexp2 = new RegExp("(?:^|\\s)"+escKey,'g');
|
2492 |
-
if(
|
2493 |
flag1 = true;
|
2494 |
}
|
2495 |
|
2496 |
-
while (
|
2497 |
-
|
2498 |
-
|
2499 |
-
|
2500 |
}
|
2501 |
-
|
2502 |
-
if(
|
2503 |
return true;
|
2504 |
-
}else{
|
2505 |
return false;
|
2506 |
}
|
2507 |
|
2508 |
}
|
2509 |
|
2510 |
|
2511 |
-
|
2512 |
/**
|
2513 |
* replaces single new-lines with space
|
2514 |
* if multiple new lines are following each other then replaces all newlines with single space
|
2515 |
* @param {String} string [input string]
|
2516 |
* @return {String} [output string]
|
2517 |
*/
|
2518 |
-
wdi_front.replaceNewLines = function(
|
|
|
2519 |
var delimeter = "vUkCJvN2ps3t",
|
2520 |
matchIndexes = [],
|
2521 |
regexp;
|
2522 |
-
string = string.replace(
|
2523 |
|
2524 |
-
regexp = new RegExp(delimeter,'g');
|
2525 |
-
while (
|
2526 |
-
|
2527 |
}
|
2528 |
|
2529 |
var pieces = string.split(delimeter);
|
2530 |
var foundFlag = 0;
|
2531 |
|
2532 |
-
for(
|
2533 |
-
|
2534 |
-
if(
|
2535 |
foundFlag++;
|
2536 |
-
}else{
|
2537 |
foundFlag = 0;
|
2538 |
}
|
2539 |
|
2540 |
-
if(foundFlag > 0){
|
2541 |
-
pieces.splice(i,1);
|
2542 |
foundFlag--;
|
2543 |
i--;
|
2544 |
}
|
@@ -2549,16 +2722,18 @@ wdi_front.replaceNewLines = function( string ){
|
|
2549 |
}
|
2550 |
|
2551 |
|
2552 |
-
wdi_front.isEmptyObject = function(obj)
|
2553 |
-
|
2554 |
-
|
2555 |
-
|
2556 |
-
|
2557 |
-
|
|
|
2558 |
}
|
2559 |
|
2560 |
|
2561 |
-
var WDIFeed = function(obj)
|
|
|
2562 |
this['data'] = obj['data']
|
2563 |
this['dataCount'] = obj['dataCount']
|
2564 |
this['feed_row'] = obj['feed_row']
|
@@ -2571,25 +2746,26 @@ var WDIFeed = function(obj) {
|
|
2571 |
* @param {Object} args [some custom arguments ]
|
2572 |
* @return {Object} [instagram API response]
|
2573 |
*/
|
2574 |
-
WDIFeed.prototype.conditionalFilter = function(response, args)
|
|
|
2575 |
|
2576 |
var currentFeed = this,
|
2577 |
conditional_filter_type = currentFeed.feed_row.conditional_filter_type,
|
2578 |
filters = currentFeed.feed_row.conditional_filters;
|
2579 |
-
|
2580 |
|
2581 |
-
if(args.ignoreFiltering == true){
|
2582 |
|
2583 |
-
|
2584 |
-
|
|
|
|
|
2585 |
/**
|
2586 |
* Get rid of duplicate media
|
2587 |
*/
|
2588 |
-
response = this.avoidDuplicateMedia(
|
2589 |
}
|
2590 |
-
|
2591 |
|
2592 |
-
|
|
|
2593 |
if (!wdi_front.isJsonString(filters)) {
|
2594 |
return response;
|
2595 |
} else {
|
@@ -2600,10 +2776,11 @@ WDIFeed.prototype.conditionalFilter = function(response, args) {
|
|
2600 |
}
|
2601 |
|
2602 |
|
2603 |
-
if(
|
2604 |
return response;
|
2605 |
}
|
2606 |
|
|
|
2607 |
//console.log('filtering');
|
2608 |
//increase counter for determing request count if this counter is more then
|
2609 |
//currentFeed.maxConditionalFiltersRequestCount then program will terminate recursion loop
|
@@ -2611,24 +2788,24 @@ WDIFeed.prototype.conditionalFilter = function(response, args) {
|
|
2611 |
|
2612 |
switch (conditional_filter_type) {
|
2613 |
case 'AND':
|
2614 |
-
|
2615 |
-
|
2616 |
-
|
2617 |
-
|
2618 |
case 'OR':
|
2619 |
-
|
2620 |
-
|
2621 |
-
|
2622 |
-
|
2623 |
case 'NOR':
|
2624 |
-
|
2625 |
-
|
2626 |
-
|
2627 |
-
|
2628 |
default:
|
2629 |
-
|
2630 |
-
|
2631 |
-
|
2632 |
}
|
2633 |
|
2634 |
|
@@ -2636,14 +2813,14 @@ WDIFeed.prototype.conditionalFilter = function(response, args) {
|
|
2636 |
}
|
2637 |
|
2638 |
|
2639 |
-
|
2640 |
/**
|
2641 |
* Return those elements which meet filters conditions
|
2642 |
* @param {Object} response [instagram API response]
|
2643 |
* @param {Array} filters [Array of filter objects]
|
2644 |
* @return {Object} [filtered response]
|
2645 |
*/
|
2646 |
-
WDIFeed.prototype.applyANDLogic = function(response, filters)
|
|
|
2647 |
var currentFeed = this;
|
2648 |
for (var i = 0; i < filters.length; i++) {
|
2649 |
response = this.filterResponse(response, filters[i]);
|
@@ -2658,7 +2835,8 @@ WDIFeed.prototype.applyANDLogic = function(response, filters) {
|
|
2658 |
* @param {Array} filters [Array of filter objects]
|
2659 |
* @return {Object} [filtered response]
|
2660 |
*/
|
2661 |
-
WDIFeed.prototype.applyORLogic = function(response, filters)
|
|
|
2662 |
var currentFeed = this;
|
2663 |
var allData = [],
|
2664 |
res,
|
@@ -2688,21 +2866,21 @@ WDIFeed.prototype.applyORLogic = function(response, filters) {
|
|
2688 |
}
|
2689 |
|
2690 |
|
2691 |
-
|
2692 |
/**
|
2693 |
* Return those elements which meet filters conditions
|
2694 |
* @param {Object} response [instagram API response]
|
2695 |
* @param {Array} filters [Array of filter objects]
|
2696 |
* @return {Object} [filtered response]
|
2697 |
*/
|
2698 |
-
WDIFeed.prototype.applyNORLogic = function(response, filters)
|
|
|
2699 |
|
2700 |
var res = response,
|
2701 |
currentFeed = this,
|
2702 |
matchedData = this.applyORLogic(response, filters, currentFeed),
|
2703 |
mergedData = [],
|
2704 |
returnObject;
|
2705 |
-
|
2706 |
for (var i = 0; i < res['data'].length; i++) {
|
2707 |
if (!this.mediaExists(res['data'][i], matchedData['data'])) {
|
2708 |
mergedData.push(res['data'][i]);
|
@@ -2718,8 +2896,9 @@ WDIFeed.prototype.applyNORLogic = function(response, filters) {
|
|
2718 |
}
|
2719 |
|
2720 |
|
2721 |
-
WDIFeed.prototype.mediaExists = function(media, array)
|
2722 |
-
|
|
|
2723 |
for (var i = 0; i < array.length; i++) {
|
2724 |
if (media['id'] == array[i]['id']) {
|
2725 |
return true;
|
@@ -2735,51 +2914,52 @@ WDIFeed.prototype.mediaExists = function(media, array) {
|
|
2735 |
* @param {Object} filter [filter object created in backend]
|
2736 |
* @return {Object} [filtered response]
|
2737 |
*/
|
2738 |
-
WDIFeed.prototype.filterResponse = function(response, filter)
|
|
|
2739 |
|
2740 |
switch (filter.filter_type) {
|
2741 |
case 'hashtag':
|
2742 |
-
|
2743 |
-
|
2744 |
-
|
2745 |
-
|
2746 |
case 'username':
|
2747 |
-
|
2748 |
-
|
2749 |
-
|
2750 |
-
|
2751 |
case 'mention':
|
2752 |
-
|
2753 |
-
|
2754 |
-
|
2755 |
-
|
2756 |
case 'description':
|
2757 |
-
|
2758 |
-
|
2759 |
-
|
2760 |
-
|
2761 |
case 'location':
|
2762 |
-
|
2763 |
-
|
2764 |
-
|
2765 |
-
|
2766 |
case 'url':
|
2767 |
-
|
2768 |
-
|
2769 |
-
|
2770 |
-
|
2771 |
}
|
2772 |
}
|
2773 |
|
2774 |
|
2775 |
-
|
2776 |
/**
|
2777 |
* filters data by given hastag filter and returns filtered response
|
2778 |
* @param {Object} response [instagram API response]
|
2779 |
* @param {Object} filter [hashtag filter object]
|
2780 |
* @return {Object} [filtered response]
|
2781 |
*/
|
2782 |
-
WDIFeed.prototype.filterByHashtag = function(response, filter)
|
|
|
2783 |
var filteredResponse = [],
|
2784 |
currentTag,
|
2785 |
media,
|
@@ -2811,7 +2991,8 @@ WDIFeed.prototype.filterByHashtag = function(response, filter) {
|
|
2811 |
* @param {Object} filter [hashtag filter object]
|
2812 |
* @return {Object} [filtered response]
|
2813 |
*/
|
2814 |
-
WDIFeed.prototype.filterByUsername = function(response, filter)
|
|
|
2815 |
var filteredResponse = [],
|
2816 |
media,
|
2817 |
returnObject;
|
@@ -2839,7 +3020,8 @@ WDIFeed.prototype.filterByUsername = function(response, filter) {
|
|
2839 |
* @param {Object} filter [hashtag filter object]
|
2840 |
* @return {Object} [filtered response]
|
2841 |
*/
|
2842 |
-
WDIFeed.prototype.filterByMention = function(response, filter)
|
|
|
2843 |
var filteredResponse = [],
|
2844 |
media, captionText, returnObject;
|
2845 |
for (var i = 0; i < response['data'].length; i++) {
|
@@ -2868,24 +3050,25 @@ WDIFeed.prototype.filterByMention = function(response, filter) {
|
|
2868 |
* @param {Object} filter [hashtag filter object]
|
2869 |
* @return {Object} [filtered response]
|
2870 |
*/
|
2871 |
-
WDIFeed.prototype.filterByDescription = function(response, filter)
|
|
|
2872 |
var filteredResponse = [],
|
2873 |
media, captionText, returnObject;
|
2874 |
|
2875 |
for (var i = 0; i < response['data'].length; i++) {
|
2876 |
media = response['data'][i];
|
2877 |
if (media['caption'] !== null) {
|
2878 |
-
|
2879 |
captionText = media['caption']['text'].toLowerCase();
|
2880 |
-
captionText = wdi_front.replaceNewLines(
|
2881 |
var searchkey = filter.filter_by.toLowerCase();
|
2882 |
-
|
2883 |
-
if(
|
2884 |
filteredResponse.push(media);
|
2885 |
}
|
2886 |
}
|
2887 |
}
|
2888 |
-
|
2889 |
returnObject = {
|
2890 |
data: filteredResponse,
|
2891 |
meta: response['meta'],
|
@@ -2895,7 +3078,6 @@ WDIFeed.prototype.filterByDescription = function(response, filter) {
|
|
2895 |
return returnObject;
|
2896 |
}
|
2897 |
|
2898 |
-
|
2899 |
|
2900 |
/**
|
2901 |
* filters data by given location filter and returns filtered response
|
@@ -2903,7 +3085,8 @@ WDIFeed.prototype.filterByDescription = function(response, filter) {
|
|
2903 |
* @param {Object} filter [hashtag filter object]
|
2904 |
* @return {Object} [filtered response]
|
2905 |
*/
|
2906 |
-
WDIFeed.prototype.filterByLocation = function(response, filter)
|
|
|
2907 |
var filteredResponse = [],
|
2908 |
media, locationId, returnObject;
|
2909 |
for (var i = 0; i < response['data'].length; i++) {
|
@@ -2933,7 +3116,8 @@ WDIFeed.prototype.filterByLocation = function(response, filter) {
|
|
2933 |
* @return {Object} [filtered response]
|
2934 |
*/
|
2935 |
|
2936 |
-
WDIFeed.prototype.filterByUrl = function(response, filter)
|
|
|
2937 |
var filteredResponse = [],
|
2938 |
media, id, returnObject, filter_by;
|
2939 |
|
@@ -2961,9 +3145,10 @@ WDIFeed.prototype.filterByUrl = function(response, filter) {
|
|
2961 |
/**
|
2962 |
* gets id of media from url, this id is not the one which comes with api request
|
2963 |
* @param {String} url [media url]
|
2964 |
-
* @return {String}
|
2965 |
*/
|
2966 |
-
WDIFeed.prototype.getIdFromUrl = function(url)
|
|
|
2967 |
var url_parts = url.split('/'),
|
2968 |
id = false;
|
2969 |
for (var i = 0; i < url_parts.length; i++) {
|
@@ -2973,7 +3158,8 @@ WDIFeed.prototype.getIdFromUrl = function(url) {
|
|
2973 |
break;
|
2974 |
}
|
2975 |
}
|
2976 |
-
}
|
|
|
2977 |
return id;
|
2978 |
}
|
2979 |
|
@@ -2983,14 +3169,15 @@ WDIFeed.prototype.getIdFromUrl = function(url) {
|
|
2983 |
* @param {Object} response [Instagram API request]
|
2984 |
* @return {Object} [response]
|
2985 |
*/
|
2986 |
-
WDIFeed.prototype.avoidDuplicateMedia = function (
|
|
|
2987 |
var data = response['data'],
|
2988 |
uniqueData = [],
|
2989 |
returnObject = {};
|
2990 |
|
2991 |
-
for(
|
2992 |
-
if(
|
2993 |
-
uniqueData.push(
|
2994 |
}
|
2995 |
}
|
2996 |
|
@@ -3001,69 +3188,79 @@ WDIFeed.prototype.avoidDuplicateMedia = function ( response ){
|
|
3001 |
meta: response['meta'],
|
3002 |
pagination: response['pagination']
|
3003 |
}
|
3004 |
-
|
3005 |
return returnObject;
|
3006 |
|
3007 |
}
|
3008 |
|
3009 |
|
3010 |
/* stores data from objects array into global variable */
|
3011 |
-
WDIFeed.prototype.storeRawData = function(
|
|
|
3012 |
var _this = this;
|
3013 |
-
if(
|
3014 |
//checks if in golbal storage user already exisit then it adds new data to user old data
|
3015 |
//else it simple puches new user with it's data to global storage
|
3016 |
-
for(
|
|
|
3017 |
|
3018 |
-
|
3019 |
var hash_id = "";
|
3020 |
-
|
3021 |
-
if( wdi_front.isHashtag( objects[i].user_id )){
|
3022 |
hash_id = objects[i].pagination.next_max_tag_id;
|
3023 |
-
}else{
|
3024 |
-
hash_id = objects[i].pagination.next_max_id;
|
3025 |
-
if ( typeof hash_id == "undefined"){
|
3026 |
-
hash_id = "";
|
3027 |
-
}
|
3028 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3029 |
|
3030 |
-
if(
|
3031 |
-
this[variable].push(
|
3032 |
-
data
|
3033 |
index: 0,
|
3034 |
locked: false,
|
3035 |
hash_id: hash_id,
|
3036 |
usersDataFinished: false,
|
3037 |
-
userId
|
3038 |
-
length: function()
|
|
|
3039 |
return this.data.length - this.index;
|
3040 |
},
|
3041 |
-
getData: function(
|
3042 |
-
|
3043 |
-
|
3044 |
-
|
3045 |
-
|
3046 |
-
|
3047 |
-
|
3048 |
-
|
|
|
3049 |
_this.usersData[j].finished = "finished";
|
3050 |
this.usersDataFinished = true;
|
3051 |
-
break;
|
3052 |
}
|
3053 |
}
|
3054 |
}
|
3055 |
return data;
|
3056 |
}
|
3057 |
-
}
|
3058 |
-
}else{
|
3059 |
-
if(
|
3060 |
-
|
3061 |
-
if(
|
3062 |
-
this[variable][i].data = this[variable][i].data.concat(
|
3063 |
this[variable][i].hash_id = hash_id;
|
3064 |
-
}else{
|
3065 |
this[variable][i].locked = true;
|
3066 |
-
|
3067 |
}
|
3068 |
}
|
3069 |
|
@@ -3074,61 +3271,65 @@ WDIFeed.prototype.storeRawData = function( objects, variable ){
|
|
3074 |
}
|
3075 |
|
3076 |
|
3077 |
-
wdi_front.updateUsersIfNecessary = function(currentFeed)
|
|
|
3078 |
var users = currentFeed.feed_users;
|
3079 |
var ifUpdateNecessary = false;
|
3080 |
|
3081 |
-
for(
|
3082 |
-
if(
|
3083 |
users[i].id = users[i].username;
|
3084 |
continue;
|
3085 |
}
|
3086 |
-
if(
|
3087 |
|
3088 |
ifUpdateNecessary = true;
|
3089 |
-
currentFeed.instagram.searchForUsersByName(
|
3090 |
-
success: function(res)
|
3091 |
-
|
|
|
3092 |
|
3093 |
var found = false;
|
3094 |
-
|
3095 |
-
for(
|
3096 |
-
if(
|
3097 |
found = true;
|
3098 |
break;
|
3099 |
}
|
3100 |
}
|
3101 |
|
3102 |
-
if(
|
3103 |
-
for(
|
3104 |
-
if(
|
3105 |
users[j].id = res.data[k].id;
|
3106 |
}
|
3107 |
}
|
3108 |
}
|
3109 |
|
3110 |
|
3111 |
-
|
3112 |
}
|
3113 |
-
|
3114 |
var noid_user_left = false;
|
3115 |
-
for(var m = 0; m < users.length; m++
|
3116 |
-
if(users[m].id == "" || users[m].id == "username"){
|
3117 |
noid_user_left = true;
|
3118 |
break;
|
3119 |
}
|
3120 |
}
|
3121 |
-
if(
|
3122 |
-
currentFeed.feed_row.feed_users = JSON.stringify(
|
3123 |
-
wdi_front.init(
|
3124 |
}
|
3125 |
-
|
3126 |
},
|
3127 |
-
username
|
3128 |
-
}
|
3129 |
}
|
3130 |
}
|
3131 |
|
3132 |
return ifUpdateNecessary;
|
3133 |
}
|
3134 |
|
|
|
|
|
|
|
|
1 |
if (typeof wdi_front == 'undefined') {
|
2 |
wdi_front = {
|
3 |
type: 'not_declared'
|
4 |
};
|
5 |
}
|
6 |
+
jQuery(document).ready(function ()
|
7 |
+
{
|
8 |
if (wdi_front['type'] != 'not_declared') {
|
9 |
wdi_front.clickOrTouch = wdi_front.detectEvent();
|
10 |
//initializing all feeds in the page
|
16 |
});
|
17 |
|
18 |
|
19 |
+
wdi_front.detectEvent = function ()
|
20 |
+
{
|
21 |
var isMobile = (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()));
|
22 |
if (isMobile) {
|
23 |
return "touchend";
|
26 |
}
|
27 |
}
|
28 |
|
29 |
+
wdi_front.globalInit = function ()
|
30 |
+
{
|
31 |
var num = wdi_front['feed_counter'];
|
32 |
|
33 |
|
|
|
34 |
for (var i = 0; i <= num; i++) {
|
35 |
|
36 |
var currentFeed = new WDIFeed(window['wdi_feed_' + i]);
|
46 |
feed: currentFeed
|
47 |
};
|
48 |
|
49 |
+
currentFeed.instagram.filters = [
|
50 |
+
{
|
51 |
+
'where': 'getUserRecentMedia',
|
52 |
+
'what': function (response, args, cArgs)
|
53 |
+
{
|
54 |
+
return args.feed.conditionalFilter(response, cArgs);
|
55 |
+
}
|
56 |
+
},
|
57 |
+
{
|
58 |
+
'where': 'getTagRecentMedia',
|
59 |
+
'what': function (response, args, cArgs)
|
60 |
+
{
|
61 |
+
return args.feed.conditionalFilter(response, cArgs);
|
62 |
+
}
|
63 |
+
},
|
64 |
+
{
|
65 |
+
'where': 'getRecentLikedMedia',
|
66 |
+
'what': function (response, args, cArgs)
|
67 |
+
{
|
68 |
+
return args.feed.conditionalFilter(response, cArgs);
|
69 |
+
}
|
70 |
+
},
|
71 |
+
|
72 |
+
|
73 |
+
{
|
74 |
+
'where': 'requestByUrl',
|
75 |
+
'what': function (response, args, cArgs)
|
76 |
+
{
|
77 |
+
return args.feed.conditionalFilter(response, cArgs);
|
78 |
+
}
|
79 |
+
},];
|
80 |
|
81 |
|
82 |
currentFeed.instagram.addToken(currentFeed['feed_row']['access_token']);
|
103 |
currentFeed.customFilterChanged = false; //flag to notice filter change, onclick on username
|
104 |
|
105 |
|
|
|
106 |
/**
|
107 |
* This variable describes after how many requests program will stop searching for content
|
108 |
* this number is very important and should not be set too high, because when feed has conditional filter
|
109 |
* and filtered items are rare then the program will recursively request new photos and will filter them
|
110 |
* if no image was fount it will go into infinite loop if feed images are "infinite" ( very huge number )
|
111 |
* and if requests count in 1 hour exeed 5000 instagram will block access token for one hour
|
112 |
+
*
|
113 |
* @type {Number}
|
114 |
*/
|
115 |
currentFeed.maxConditionalFiltersRequestCount = 10;
|
117 |
/**
|
118 |
* This variable shows us how many times program has been recursively called,
|
119 |
* it changes it value within filtering function, and resets itself to 0 when feed is being displayed
|
120 |
+
*
|
121 |
* @type {Number}
|
122 |
*/
|
123 |
currentFeed.instagramRequestCounter = 0;
|
126 |
* This array stores data from each request,
|
127 |
* it is used to determine and remove duplicate photos caused by multiple hashtags
|
128 |
* it is resetted to its inital [] value after displaying feed
|
129 |
+
*
|
130 |
* @type {Array}
|
131 |
*/
|
132 |
currentFeed.conditionalFilterBuffer = [];
|
134 |
|
135 |
currentFeed.stopInfiniteScrollFlag = false;
|
136 |
|
137 |
+
window.onload = function ()
|
138 |
+
{
|
139 |
for (var i = 0; i <= wdi_front.feed_counter; i++) {
|
140 |
window['wdi_feed_' + i]['nowLoadingImages'] = false;
|
141 |
}
|
146 |
}
|
147 |
|
148 |
|
|
|
149 |
//if pagination is on then set pagination parameters
|
150 |
if (currentFeed.feed_row.feed_display_view == 'pagination') {
|
151 |
currentFeed.feed_row.resort_after_load_more = 0;
|
165 |
|
166 |
|
167 |
//initializing function for lightbox
|
168 |
+
currentFeed.galleryBox = function (image_id)
|
169 |
+
{
|
170 |
+
wdi_spider_createpopup(wdi_url.ajax_url + '?gallery_id=' + this.feed_row['id'] + '&image_id=' + image_id, wdi_front.feed_counter, this.feed_row['lightbox_width'], this.feed_row['lightbox_height'], 1, 'testpopup', 5, this);
|
171 |
+
}
|
172 |
+
//calling responive javascript
|
173 |
wdi_responsive.columnControl(currentFeed);
|
174 |
|
175 |
//if feed type is masonry then trigger resize event for building proper column layout
|
182 |
window['wdi_feed_' + i] = currentFeed;
|
183 |
|
184 |
|
|
|
185 |
//initializing each feed
|
186 |
wdi_front.init(currentFeed);
|
187 |
} //endfor
|
188 |
|
189 |
}
|
190 |
|
191 |
+
wdi_front.init = function (currentFeed)
|
192 |
+
{
|
193 |
|
194 |
|
195 |
//some varables used in code
|
196 |
currentFeed.photoCounter = currentFeed.feed_row["number_of_photos"];
|
197 |
|
198 |
|
199 |
+
if (currentFeed.feed_row.liked_feed == 'liked') {
|
200 |
+
currentFeed.feed_users = ['self'];
|
201 |
+
// do nothing,
|
202 |
+
}
|
203 |
+
else
|
204 |
+
if (wdi_front.isJsonString(currentFeed.feed_row.feed_users)) {
|
205 |
+
/**
|
206 |
+
* Contains username and user_id of each user
|
207 |
+
* @type {[Array}
|
208 |
+
*/
|
209 |
+
currentFeed.feed_users = JSON.parse(currentFeed.feed_row.feed_users);
|
210 |
|
211 |
+
/**
|
212 |
+
* Check if feed user has no id for some reason then update user
|
213 |
+
* and after updating them initialize feed
|
214 |
+
*/
|
215 |
+
if (wdi_front.updateUsersIfNecessary(currentFeed)) {
|
216 |
+
return;
|
217 |
+
}
|
218 |
+
;
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
|
220 |
|
221 |
+
} else {
|
222 |
+
alert('provided feed users are invalid or obsolete for this version of plugin');
|
223 |
+
return;
|
224 |
+
}
|
225 |
|
226 |
|
227 |
//wdi_front.loadInstagramMedia( currentFeed, currentFeed.feed_row.number_of_photos);
|
228 |
+
|
229 |
+
currentFeed.dataCount = currentFeed.feed_users.length; //1 in case of self feed
|
230 |
+
|
231 |
+
|
232 |
+
for (var i = 0; i < currentFeed.dataCount; i++) {
|
233 |
wdi_front.instagramRequest(i, currentFeed);
|
234 |
}
|
235 |
|
251 |
}
|
252 |
|
253 |
|
|
|
254 |
/**
|
255 |
* Checks if given string is JSON string
|
256 |
* @param {String} str [string to check]
|
257 |
* @return {Boolean} [true or false]
|
258 |
*/
|
259 |
+
wdi_front.isJsonString = function (str)
|
260 |
+
{
|
261 |
try {
|
262 |
JSON.parse(str);
|
263 |
} catch (e) {
|
267 |
}
|
268 |
|
269 |
|
|
|
270 |
/**
|
271 |
* Makes an ajax request for given user from feed_users array
|
272 |
* if response is ok then calls saveUserData function
|
273 |
+
* if liked media to show, feed user is self
|
274 |
* @param {Number} id [index of user in current_feed.feed_users array]
|
275 |
+
* @param {Object} currentFeed
|
276 |
*/
|
277 |
+
wdi_front.instagramRequest = function (id, currentFeed)
|
278 |
+
{
|
279 |
|
280 |
var feed_users = currentFeed.feed_users,
|
281 |
_this = this;
|
282 |
+
if (typeof feed_users[id] === 'string' && feed_users[id] === 'self') { // self liked media
|
283 |
+
currentFeed.instagram.getRecentLikedMedia({
|
284 |
+
success: function (response)
|
285 |
{
|
286 |
+
response = _this.checkMediaResponse(response);
|
287 |
+
if (response != false) {
|
288 |
+
_this.saveSelfUserData(response, currentFeed);
|
289 |
+
}
|
|
|
|
|
|
|
|
|
|
|
290 |
}
|
291 |
+
});
|
292 |
+
}
|
293 |
+
else
|
294 |
+
if (this.getInputType(feed_users[id]['username']) == 'hashtag') {
|
295 |
+
currentFeed.instagram.getTagRecentMedia(this.stripHashtag(feed_users[id]['username']), {
|
296 |
+
success: function (response)
|
297 |
+
{
|
298 |
+
response = _this.checkMediaResponse(response);
|
299 |
+
if (response != false) {
|
300 |
+
_this.saveUserData(response, currentFeed.feed_users[id], currentFeed);
|
301 |
+
}
|
302 |
+
}
|
303 |
+
});
|
304 |
+
}
|
305 |
+
else
|
306 |
+
if (this.getInputType(feed_users[id]['username']) == 'user') {
|
307 |
currentFeed.instagram.getUserRecentMedia(feed_users[id]['id'], {
|
308 |
+
success: function (response)
|
309 |
+
{
|
310 |
response = _this.checkMediaResponse(response);
|
311 |
if (response != false) {
|
312 |
_this.saveUserData(response, currentFeed.feed_users[id], currentFeed);
|
313 |
}
|
314 |
}
|
315 |
+
});
|
|
|
316 |
}
|
317 |
+
|
318 |
}
|
319 |
|
320 |
/**
|
321 |
* Returns true is given string starts with dash ( # )
|
322 |
+
* @param {String} str
|
323 |
* @return {Boolean} [true or false]
|
324 |
*/
|
325 |
+
wdi_front.isHashtag = function (str)
|
326 |
+
{
|
327 |
return (str[0] === '#');
|
328 |
}
|
329 |
|
332 |
* Saves each user data on seperate index in currentFeed.usersData array
|
333 |
* And also checks if all data form all users is already avialable if yes it displays feed
|
334 |
*/
|
335 |
+
wdi_front.saveUserData = function (data, user, currentFeed)
|
336 |
+
{
|
337 |
|
338 |
data['username'] = user.username;
|
339 |
data['user_id'] = user.id;
|
352 |
currentFeed.allResponseLength += currentFeed.currentResponseLength;
|
353 |
|
354 |
|
|
|
355 |
if (currentFeed.dataCount == currentFeed.usersData.length) {
|
356 |
|
357 |
//if getted objects is not enough then recuest new ones
|
|
|
358 |
if (currentFeed.currentResponseLength < currentFeed.feed_row.number_of_photos && !wdi_front.userHasNoPhoto(currentFeed)) {
|
359 |
//console.log('initial recursion');
|
360 |
/*here we are calling loadMore function out of recursion cylce, after this initial-keep call
|
361 |
+
loadMore will be called with 'initial' recursivly until the desired number of photos is reached
|
362 |
+
if possible*/
|
363 |
|
364 |
wdi_front.loadMore('initial-keep', currentFeed);
|
365 |
} else {
|
369 |
wdi_front.displayFeed(currentFeed);
|
370 |
//when all data us properly displayed check for any active filters and then apply them
|
371 |
wdi_front.applyFilters(currentFeed);
|
372 |
+
|
373 |
|
374 |
/*removing load more button of feed has finished*/
|
375 |
+
if (!wdi_front.activeUsersCount(currentFeed)) {
|
376 |
if (currentFeed.feed_row.feed_display_view == 'load_more_btn') {
|
377 |
var feed_container = jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter);
|
378 |
feed_container.find('.wdi_load_more').addClass('wdi_hidden');
|
379 |
feed_container.find('.wdi_spinner').addClass('wdi_hidden');
|
380 |
}
|
381 |
+
}
|
382 |
+
;
|
383 |
+
|
384 |
+
}
|
385 |
+
|
386 |
+
|
387 |
+
}
|
388 |
+
|
389 |
+
}
|
390 |
+
|
391 |
+
|
392 |
+
/*
|
393 |
+
* Saves self user data on separate index in currentFeed.usersData array
|
394 |
+
* And also checks if all data form all users is already avialable if yes it displays feed
|
395 |
+
*/
|
396 |
+
wdi_front.saveSelfUserData = function (data, currentFeed)
|
397 |
+
{
|
398 |
+
|
399 |
+
//keep empty for self feed
|
400 |
+
data['username'] = '';
|
401 |
+
data['user_id'] = '';
|
402 |
+
|
403 |
+
currentFeed.usersData.push(data);
|
404 |
+
|
405 |
+
|
406 |
+
currentFeed.currentResponseLength = wdi_front.getArrayContentLength(currentFeed.usersData, 'data');
|
407 |
+
currentFeed.allResponseLength += currentFeed.currentResponseLength;
|
408 |
+
|
409 |
+
|
410 |
+
if (currentFeed.dataCount == currentFeed.usersData.length) {
|
411 |
+
|
412 |
+
//if retrieved objects are not enough then request new ones
|
413 |
+
|
414 |
+
if (currentFeed.currentResponseLength < currentFeed.feed_row.number_of_photos && !wdi_front.userHasNoPhoto(currentFeed)) {
|
415 |
+
//console.log('initial recursion');
|
416 |
+
/*here we are calling loadMore function out of recursion cycle, after this initial-keep call
|
417 |
+
loadMore will be called with 'initial' recursively until the desired number of photos is reached
|
418 |
+
if possible*/
|
419 |
+
|
420 |
+
wdi_front.loadMore('initial-keep', currentFeed);
|
421 |
+
} else {
|
422 |
+
|
423 |
+
|
424 |
+
//display feed
|
425 |
+
wdi_front.displayFeed(currentFeed);
|
426 |
+
//when all data us properly displayed check for any active filters and then apply them
|
427 |
+
wdi_front.applyFilters(currentFeed);
|
428 |
+
|
429 |
+
|
430 |
+
/*removing load more button of feed has finished*/
|
431 |
+
if (!wdi_front.activeUsersCount(currentFeed)) {
|
432 |
+
if (currentFeed.feed_row.feed_display_view == 'load_more_btn') {
|
433 |
+
var feed_container = jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter);
|
434 |
+
feed_container.find('.wdi_load_more').addClass('wdi_hidden');
|
435 |
+
feed_container.find('.wdi_spinner').addClass('wdi_hidden');
|
436 |
+
}
|
437 |
+
}
|
438 |
+
;
|
439 |
|
440 |
}
|
441 |
|
447 |
/**
|
448 |
* checks weather all feed users have any photos after first time request
|
449 |
*/
|
450 |
+
wdi_front.userHasNoPhoto = function (currentFeed, cstData)
|
451 |
+
{
|
452 |
+
|
453 |
var counter = 0;
|
454 |
var data = currentFeed.usersData;
|
455 |
+
if (typeof cstData != 'undefined') {
|
456 |
data = cstData;
|
457 |
}
|
458 |
for (var i = 0; i < data.length; i++) {
|
459 |
+
if (currentFeed.feed_row.liked_feed === 'liked') {
|
460 |
+
if (typeof data[i]['pagination']['next_max_like_id'] == 'undefined') {
|
461 |
+
counter++
|
462 |
+
}
|
463 |
+
}
|
464 |
+
else {
|
465 |
+
if (typeof data[i]['pagination']['next_max_id'] == 'undefined') {
|
466 |
+
counter++
|
467 |
+
}
|
468 |
}
|
469 |
+
|
470 |
}
|
471 |
if (counter == data.length) {
|
472 |
return 1;
|
478 |
/*
|
479 |
*gives each instagram object custom hashtag parameter, which is used for searching image/video
|
480 |
*/
|
481 |
+
wdi_front.appendRequestHashtag = function (data, hashtag)
|
482 |
+
{
|
483 |
for (var i = 0; i < data.length; i++) {
|
484 |
data[i]['wdi_hashtag'] = hashtag;
|
485 |
}
|
487 |
}
|
488 |
|
489 |
|
|
|
490 |
/*
|
491 |
* sorts data based on user choice and displays feed
|
492 |
* also checks if one request is not enough for displaying all images user wanted
|
493 |
* it recursively calls wdi_front.loadMore() until the desired number of photos is reached
|
494 |
*/
|
495 |
+
wdi_front.displayFeed = function (currentFeed, load_more_number)
|
496 |
+
{
|
497 |
|
498 |
|
499 |
if (currentFeed.customFilterChanged == false) {
|
533 |
}
|
534 |
|
535 |
//checking feed_type and calling proper rendering functions
|
536 |
+
if (currentFeed.feed_row.feed_type == 'masonry') {
|
537 |
wdi_front.masonryDisplayFeedItems(data, currentFeed);
|
538 |
}
|
539 |
+
if (currentFeed.feed_row.feed_type == 'thumbnails' || currentFeed.feed_row.feed_type == 'blog_style' || currentFeed.feed_row.feed_type == 'image_browser') {
|
540 |
+
wdi_front.displayFeedItems(data, currentFeed);
|
541 |
}
|
542 |
|
543 |
|
|
|
544 |
//recursively calling load more to get photos
|
545 |
+
var dataLength = wdi_front.getDataLength(currentFeed);
|
546 |
|
547 |
|
548 |
+
if (dataLength < currentFeed.photoCounter && !frontendCustomFilterClicked && currentFeed.instagramRequestCounter <= currentFeed.maxConditionalFiltersRequestCount && !wdi_front.allDataHasFinished(currentFeed)) {
|
549 |
+
wdi_front.loadMore('', currentFeed);
|
550 |
|
551 |
} else {
|
552 |
wdi_front.allImagesLoaded(currentFeed);
|
556 |
/**
|
557 |
* if maximum number of requests are reached then stop laoding more images and show images which are available
|
558 |
* @param {Number} currentFeed.instagramRequestCounter > currentFeed.maxConditionalFiltersRequestCount [description]
|
559 |
+
* @return {Boolean}
|
560 |
*/
|
561 |
if (currentFeed.instagramRequestCounter > currentFeed.maxConditionalFiltersRequestCount) {
|
562 |
wdi_front.allImagesLoaded(currentFeed);
|
576 |
}
|
577 |
|
578 |
|
|
|
579 |
// reset instagram request counter to zero for next set of requests
|
580 |
currentFeed.instagramRequestCounter = 0;
|
581 |
|
586 |
wdi_front.updateUsersImages(currentFeed);
|
587 |
|
588 |
|
|
|
|
|
589 |
// /**
|
590 |
// * Enable image lazy laoding if pagination is not enabeled because pagination has option for preloading images
|
591 |
+
// * which is the opposide of lazy load
|
592 |
// */
|
593 |
// if( currentFeed.feed_row.feed_display_view != 'pagination' ){
|
594 |
// jQuery(function() {
|
599 |
// });
|
600 |
|
601 |
// }
|
602 |
+
|
603 |
}
|
604 |
|
605 |
/**
|
607 |
* then update source
|
608 |
* @param {Object} currentFeed [description]
|
609 |
*/
|
610 |
+
wdi_front.updateUsersImages = function (currentFeed)
|
611 |
+
{
|
612 |
var elements = jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter).find('.wdi_single_user .wdi_user_img_wrap img');
|
613 |
+
elements.each(function ()
|
614 |
+
{
|
615 |
if (jQuery(this).attr('src') == wdi_url.plugin_url + '../images/missing.png' || jQuery(this).attr('src') == '') {
|
616 |
//console.log('missing');
|
617 |
+
|
618 |
+
if (currentFeed.feed_row.liked_feed == 'liked') {
|
619 |
+
return;
|
620 |
+
}
|
621 |
+
|
622 |
+
|
623 |
for (var j = 0; j < currentFeed.usersData.length; j++) {
|
624 |
if (currentFeed.usersData[j]['username'] == jQuery(this).parent().parent().find('h3').text()) {
|
625 |
if (currentFeed.usersData[j]['data'].length != 0) {
|
632 |
}
|
633 |
|
634 |
|
|
|
635 |
/**
|
636 |
* Displays data in masonry layout
|
637 |
* @param {Object} data data to be displayed
|
638 |
+
* @param {Object} currentFeed
|
639 |
*/
|
640 |
+
wdi_front.masonryDisplayFeedItems = function (data, currentFeed)
|
641 |
+
{
|
642 |
var masonryColEnds = [];
|
643 |
var masonryColumns = [];
|
644 |
+
if (jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + " .wdi_feed_wrapper").length == 0) {
|
645 |
//no feed in DOM, ignore
|
646 |
return;
|
647 |
}
|
648 |
+
jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' .wdi_masonry_column').each(function ()
|
649 |
+
{
|
650 |
|
651 |
//if resorte after load more is on then reset columns on every load more
|
652 |
if (currentFeed.feed_row.resort_after_load_more == 1) {
|
716 |
var columnFlag = false;
|
717 |
currentFeed.wdi_load_count = i;
|
718 |
var wdi_feed_counter = currentFeed.feed_row['wdi_feed_counter'];
|
719 |
+
var feed_wrapper = jQuery('#wdi_feed_' + wdi_feed_counter + ' img.wdi_img').on('load', function ()
|
720 |
+
{
|
721 |
currentFeed.wdi_loadedImages++;
|
722 |
checkLoaded();
|
723 |
|
736 |
});
|
737 |
|
738 |
|
|
|
|
|
739 |
/**
|
740 |
* if feed type is not blog style then after displaying images assign click evetns to their captions
|
741 |
* this part of code is a bit differenet from free version because of image lazy loading feature
|
742 |
+
*
|
743 |
* in free version events are assigned directly in onload event, but when lazy loading added it cased duplicate event fireing
|
744 |
* so event assigning moved to here
|
745 |
+
*
|
746 |
*/
|
747 |
// if ( currentFeed.feed_row.feed_type != 'blog_style' ){
|
748 |
// jQuery('#wdi_feed_'+currentFeed.feed_row.wdi_feed_counter+' .wdi_photo_title').each(function(){
|
751 |
// }
|
752 |
|
753 |
|
|
|
|
|
754 |
//checks if all iamges have been succesfully loaded then it updates variables for next time use
|
755 |
+
function checkLoaded()
|
756 |
+
{
|
757 |
|
758 |
if (currentFeed.wdi_load_count === currentFeed.wdi_loadedImages && currentFeed.wdi_loadedImages != 0) {
|
759 |
currentFeed.loadedImages = 0;
|
775 |
}
|
776 |
|
777 |
|
|
|
778 |
/*
|
779 |
* Calcuates image resolution
|
780 |
*/
|
781 |
+
wdi_front.getImageResolution = function (data)
|
782 |
+
{
|
783 |
|
784 |
var originalWidth = data['images']['standard_resolution']['width'];
|
785 |
var originalHeight = data['images']['standard_resolution']['height'];
|
791 |
* Calculates data count on global Storage and if custom storage provied
|
792 |
* it adds custom storage data count to golbals data count and returns length of all storages
|
793 |
*/
|
794 |
+
wdi_front.getDataLength = function (currentFeed, customStorage)
|
795 |
+
{
|
796 |
+
|
797 |
var length = 0;
|
798 |
+
if (typeof customStorage === 'undefined') {
|
799 |
for (var j = 0; j < currentFeed.dataStorage.length; j++) {
|
800 |
length += currentFeed.dataStorage[j].length;
|
801 |
}
|
808 |
return length;
|
809 |
}
|
810 |
|
811 |
+
wdi_front.getArrayContentLength = function (array, data)
|
812 |
+
{
|
813 |
var sum = 0;
|
814 |
for (var i = 0; i < array.length; i++) {
|
815 |
if (array[i]['finished'] == 'finished') {
|
821 |
}
|
822 |
|
823 |
|
|
|
824 |
/**
|
825 |
* Displays data in thumbnail layout
|
826 |
* @param {Object} data data to be displayed
|
827 |
+
* @param {Object} currentFeed
|
828 |
*/
|
829 |
+
wdi_front.displayFeedItems = function (data, currentFeed)
|
830 |
+
{
|
831 |
|
832 |
//gets ready data, gets data template, and appens it into feed_wrapper
|
833 |
var wdi_feed_counter = currentFeed.feed_row['wdi_feed_counter'];
|
861 |
}
|
862 |
|
863 |
|
|
|
864 |
for (var i = 0; i < data.length; i++) {
|
865 |
if (data[i]['type'] == 'image') {
|
866 |
var photoTemplate = wdi_front.getPhotoTemplate(currentFeed);
|
891 |
|
892 |
//fixing last row in case of full caption is open
|
893 |
//for that triggering click twice to open and close caption text that will fix last row
|
894 |
+
/*ttt 1.1.12*/
|
895 |
+
//jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' .wdi_feed_wrapper [wdi_index=' + lastIndex + '] .wdi_photo_title').trigger(wdi_front.clickOrTouch);
|
896 |
+
//jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' .wdi_feed_wrapper [wdi_index=' + lastIndex + '] .wdi_photo_title').trigger(wdi_front.clickOrTouch);
|
897 |
|
898 |
|
899 |
//binding onload event for ajax loader
|
901 |
var columnFlag = false;
|
902 |
currentFeed.wdi_load_count = i;
|
903 |
var wdi_feed_counter = currentFeed.feed_row['wdi_feed_counter'];
|
904 |
+
var feed_wrapper = jQuery('#wdi_feed_' + wdi_feed_counter + ' img.wdi_img').on('load', function ()
|
905 |
+
{
|
906 |
currentFeed.wdi_loadedImages++;
|
907 |
checkLoaded();
|
908 |
|
923 |
});
|
924 |
|
925 |
|
|
|
|
|
926 |
/**
|
927 |
* if feed type is not blog style then after displaying images assign click evetns to their captions
|
928 |
* this part of code is a bit differenet from free version because of image lazy loading feature
|
929 |
+
*
|
930 |
* in free version events are assigned directly in onload event, but when lazy loading added it cased duplicate event fireing
|
931 |
* so event assigning moved to here
|
932 |
+
*
|
933 |
*/
|
934 |
// if ( currentFeed.feed_row.feed_type != 'blog_style' ){
|
935 |
// jQuery('#wdi_feed_'+currentFeed.feed_row.wdi_feed_counter+' .wdi_photo_title').each(function(){
|
939 |
// }
|
940 |
|
941 |
|
|
|
942 |
//checks if all iamges have been succesfully loaded then it updates variables for next time use
|
943 |
+
function checkLoaded()
|
944 |
+
{
|
945 |
if (currentFeed.wdi_load_count === currentFeed.wdi_loadedImages && currentFeed.wdi_loadedImages != 0) {
|
946 |
currentFeed.loadedImages = 0;
|
947 |
currentFeed.wdi_load_count = 0;
|
960 |
|
961 |
}
|
962 |
|
963 |
+
wdi_front.checkFeedFinished = function (currentFeed)
|
964 |
+
{
|
965 |
for (var i = 0; i < currentFeed.usersData.length; i++) {
|
966 |
+
if (typeof currentFeed.usersData[i]['finished'] == 'undefined') {
|
967 |
return false;
|
968 |
}
|
969 |
}
|
970 |
return true;
|
971 |
}
|
972 |
|
973 |
+
wdi_front.sortingOperator = function (sortImagesBy, sortOrder)
|
974 |
+
{
|
975 |
var operator;
|
976 |
switch (sortImagesBy) {
|
977 |
case 'date':
|
978 |
+
{
|
979 |
+
switch (sortOrder) {
|
980 |
+
case 'asc':
|
981 |
+
{
|
982 |
+
operator = function (a, b)
|
983 |
+
{
|
984 |
+
return (a['created_time'] > b['created_time']) ? 1 : -1;
|
985 |
+
}
|
986 |
+
break;
|
987 |
+
}
|
988 |
+
case 'desc':
|
989 |
+
{
|
990 |
+
operator = function (a, b)
|
991 |
+
{
|
992 |
+
return (a['created_time'] > b['created_time']) ? -1 : 1;
|
993 |
+
}
|
994 |
+
break;
|
995 |
}
|
|
|
996 |
}
|
997 |
+
break;
|
998 |
+
}
|
999 |
case 'likes':
|
1000 |
+
{
|
1001 |
+
switch (sortOrder) {
|
1002 |
+
case 'asc':
|
1003 |
+
{
|
1004 |
+
operator = function (a, b)
|
1005 |
+
{
|
1006 |
+
return (a['likes']['count'] < b['likes']['count']) ? -1 : 1;
|
1007 |
+
}
|
1008 |
+
break;
|
1009 |
+
}
|
1010 |
+
case 'desc':
|
1011 |
+
{
|
1012 |
+
operator = function (a, b)
|
1013 |
+
{
|
1014 |
+
return (a['likes']['count'] < b['likes']['count']) ? 1 : -1;
|
1015 |
+
}
|
1016 |
+
break;
|
1017 |
}
|
|
|
1018 |
}
|
1019 |
+
break;
|
1020 |
+
}
|
1021 |
case 'comments':
|
1022 |
+
{
|
1023 |
+
switch (sortOrder) {
|
1024 |
+
case 'asc':
|
1025 |
+
{
|
1026 |
+
operator = function (a, b)
|
1027 |
+
{
|
1028 |
+
return (a['comments']['count'] < b['comments']['count']) ? -1 : 1;
|
1029 |
+
}
|
1030 |
+
break;
|
1031 |
+
}
|
1032 |
+
case 'desc':
|
1033 |
+
{
|
1034 |
+
operator = function (a, b)
|
1035 |
+
{
|
1036 |
+
return (a['comments']['count'] < b['comments']['count']) ? 1 : -1;
|
1037 |
+
}
|
1038 |
+
break;
|
1039 |
}
|
|
|
1040 |
}
|
1041 |
+
break;
|
1042 |
+
}
|
1043 |
case 'random':
|
1044 |
+
{
|
1045 |
+
operator = function (a, b)
|
1046 |
{
|
1047 |
+
var num = Math.random();
|
1048 |
+
return (num > 0.5) ? 1 : -1;
|
|
|
|
|
|
|
1049 |
}
|
1050 |
+
break;
|
1051 |
+
}
|
1052 |
}
|
1053 |
return operator;
|
1054 |
}
|
1056 |
/*
|
1057 |
* Calls smart picker method and then after receiving data it sorts data based on user choice
|
1058 |
*/
|
1059 |
+
wdi_front.feedSort = function (currentFeed, load_more_number)
|
1060 |
+
{
|
1061 |
|
1062 |
var sortImagesBy = currentFeed.feed_row['sort_images_by'];
|
1063 |
var sortOrder = currentFeed.feed_row['display_order'];
|
1069 |
}
|
1070 |
|
1071 |
|
|
|
1072 |
var operator = wdi_front.sortingOperator(sortImagesBy, sortOrder);
|
1073 |
currentFeed['data'].sort(operator);
|
1074 |
return currentFeed['data'];
|
1076 |
}
|
1077 |
|
1078 |
/*
|
1079 |
+
* Filters all requested data and takes some amount of data for each user
|
1080 |
* and stops picking when it reaches number_of_photos limit
|
1081 |
*/
|
1082 |
+
wdi_front.smartPicker = function (currentFeed, load_more_number)
|
1083 |
+
{
|
1084 |
|
1085 |
var dataStorage = [];
|
1086 |
var dataLength = 0;
|
1090 |
var remainder = 0;
|
1091 |
|
1092 |
//check if loadmore was clicked
|
1093 |
+
if (load_more_number != '' && typeof load_more_number != 'undefined' && load_more_number != null) {
|
1094 |
number_of_photos = parseInt(load_more_number);
|
1095 |
perUser = Math.ceil(number_of_photos / wdi_front.activeUsersCount(currentFeed));
|
1096 |
}
|
1097 |
|
1098 |
|
1099 |
+
var sortOperator = function (a, b)
|
1100 |
+
{
|
1101 |
return (a['data'].length > b['data'].length) ? 1 : -1;
|
1102 |
}
|
1103 |
|
1104 |
+
var sortOperator1 = function (a, b)
|
1105 |
+
{
|
1106 |
return (a.length() > b.length()) ? 1 : -1;
|
1107 |
}
|
1108 |
|
|
|
1109 |
|
1110 |
// storing user data in global dataStoreageRaw variable
|
1111 |
+
currentFeed.storeRawData(currentFeed.usersData, 'dataStorageRaw');
|
1112 |
+
|
1113 |
//dataStorageRaw
|
1114 |
+
var dataStorageRaw = currentFeed['dataStorageRaw'].sort(sortOperator1);
|
1115 |
|
1116 |
//sorts user data desc
|
1117 |
var usersData = currentFeed['usersData'].sort(sortOperator);
|
1122 |
for (var i = 0; i < usersData.length; i++) {
|
1123 |
|
1124 |
remainder += perUser;
|
1125 |
+
|
1126 |
/* if data is less then amount for each user then pick all data */
|
1127 |
+
if (dataStorageRaw[i].length() <= remainder) {
|
1128 |
|
1129 |
/* update remainder */
|
1130 |
remainder -= dataStorageRaw[i].length();
|
1131 |
|
1132 |
/* get and store data */
|
1133 |
+
dataStorage.push(dataStorageRaw[i].getData(dataStorageRaw[i].length()));
|
1134 |
/* update data length */
|
1135 |
+
dataLength += dataStorage[dataStorage.length - 1].length;
|
1136 |
|
1137 |
|
1138 |
+
} else {
|
1139 |
+
if (dataLength + remainder > number_of_photos) {
|
1140 |
remainder = number_of_photos - dataLength;
|
1141 |
}
|
1142 |
|
1143 |
var pickedData = [];
|
1144 |
|
1145 |
+
|
1146 |
if (currentFeed['auto_trigger'] === false) {
|
1147 |
+
pickedData = pickedData.concat(dataStorageRaw[i].getData(remainder));
|
1148 |
} else {
|
1149 |
if (pickedData.length + wdi_front.getDataLength(currentFeed) + wdi_front.getDataLength(currentFeed, dataStorage) < currentFeed['feed_row']['number_of_photos']) {
|
1150 |
+
pickedData = pickedData.concat(dataStorageRaw[i].getData(remainder));
|
1151 |
}
|
1152 |
}
|
1153 |
|
1154 |
remainder = 0;
|
1155 |
|
1156 |
dataLength += pickedData.length;
|
1157 |
+
dataStorage.push(pickedData);
|
1158 |
|
1159 |
|
1160 |
}
|
1161 |
|
1162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1163 |
/*if (usersData[i]['data'].length <= remainder) {
|
1164 |
|
1165 |
+
var pagination = usersData[i]['pagination']['next_url'];
|
1166 |
+
if (usersData[i]['finished'] === undefined) {
|
1167 |
+
dataStorage.push(usersData[i]['data']);
|
1168 |
+
remainder -= usersData[i]['data'].length;
|
1169 |
+
dataLength += usersData[i]['data'].length;
|
1170 |
+
}
|
1171 |
+
|
1172 |
+
if (usersData[i]['finished'] === undefined) {
|
1173 |
+
if (pagination === undefined || pagination === '' || pagination === null) {
|
1174 |
+
usersData[i]['finished'] = 'finished';
|
1175 |
+
}
|
1176 |
+
}
|
1177 |
+
} else {
|
1178 |
+
if ((dataLength + remainder) > number_of_photos) {
|
1179 |
+
remainder = number_of_photos - dataLength;
|
1180 |
+
}
|
1181 |
+
var pickedData = [];
|
1182 |
+
var indexPuller = 0;
|
1183 |
+
for (var j = 0; j < remainder; j++) {
|
1184 |
+
if (currentFeed['auto_trigger'] === false) {
|
1185 |
+
if (usersData[i]['finished'] === undefined) {
|
1186 |
+
pickedData.push(usersData[i]['data'][j]);
|
1187 |
+
}
|
1188 |
+
} else {
|
1189 |
+
if (pickedData.length + wdi_front.getDataLength(currentFeed) + wdi_front.getDataLength(currentFeed, dataStorage) < currentFeed['feed_row']['number_of_photos']) {
|
1190 |
+
if (usersData[i]['finished'] === undefined) {
|
1191 |
+
pickedData.push(usersData[i]['data'][j]);
|
1192 |
+
}
|
1193 |
+
} else {
|
1194 |
+
indexPuller++;
|
1195 |
+
}
|
1196 |
+
}
|
1197 |
+
|
1198 |
+
}
|
1199 |
+
j -= indexPuller;
|
1200 |
+
|
1201 |
+
remainder = 0;
|
1202 |
+
|
1203 |
+
|
1204 |
+
|
1205 |
+
//updating pagination
|
1206 |
+
|
1207 |
+
|
1208 |
+
|
1209 |
+
//pushes picked data into local storage
|
1210 |
+
dataLength += pickedData.length;
|
1211 |
+
dataStorage.push(pickedData);
|
1212 |
+
|
1213 |
+
}*/
|
1214 |
+
}
|
1215 |
+
//checks if in golbal storage user already exisit then it adds new data to user old data
|
1216 |
//else it simple puches new user with it's data to global storage
|
1217 |
for (i = 0; i < dataStorage.length; i++) {
|
1218 |
+
if (typeof currentFeed.dataStorage[i] === 'undefined') {
|
1219 |
currentFeed.dataStorage.push(dataStorage[i]);
|
1220 |
} else {
|
1221 |
currentFeed.dataStorage[i] = currentFeed.dataStorage[i].concat(dataStorage[i]);
|
1236 |
/*
|
1237 |
* returns json object for inserting photo template
|
1238 |
*/
|
1239 |
+
wdi_front.createObject = function (obj, currentFeed)
|
1240 |
+
{
|
1241 |
|
1242 |
var caption = (obj['caption'] != null) ? obj['caption']['text'] : ' ';
|
1243 |
var image_url;
|
1283 |
/*
|
1284 |
* If pagination is on sets the proper page number
|
1285 |
*/
|
1286 |
+
wdi_front.setPage = function (currentFeed)
|
1287 |
+
{
|
1288 |
var display_type = currentFeed.feed_row.feed_display_view;
|
1289 |
var feed_type = currentFeed.feed_row.feed_type;
|
1290 |
if (display_type != 'pagination') {
|
1306 |
/*
|
1307 |
* Template for all feed items which have type=image
|
1308 |
*/
|
1309 |
+
wdi_front.getPhotoTemplate = function (currentFeed)
|
1310 |
+
{
|
1311 |
var page = wdi_front.setPage(currentFeed);
|
1312 |
var customClass = '';
|
1313 |
var pagination = '';
|
1321 |
if (page != '') {
|
1322 |
pagination = 'wdi_page="' + page + '"';
|
1323 |
sourceAttr = 'src';
|
1324 |
+
} else {
|
1325 |
sourceAttr = 'src';
|
1326 |
}
|
1327 |
|
1330 |
}
|
1331 |
|
1332 |
|
1333 |
+
if (currentFeed.feed_row.show_username_on_thumb == '1') {
|
|
|
|
|
1334 |
showUsernameOnThumb = '<span class="wdi_media_user">@<%= wdi_username%></span>';
|
1335 |
}
|
1336 |
|
1341 |
}
|
1342 |
|
1343 |
var onclickevent = "";
|
1344 |
+
if (currentFeed.feed_row.feed_type !== "blog_style") {
|
1345 |
+
if (currentFeed.feed_row.feed_type == 'masonry') {
|
1346 |
+
onclickevent = "wdi_responsive.showMasonryCaption(jQuery(this)," + currentFeed.feed_row.wdi_feed_counter + ");"
|
1347 |
+
} else {
|
1348 |
+
onclickevent = "wdi_responsive.showCaption(jQuery(this)," + currentFeed.feed_row.wdi_feed_counter + ");";
|
1349 |
}
|
1350 |
|
1351 |
}
|
1354 |
//creating onclick string for different options
|
1355 |
switch (currentFeed.feed_row.feed_item_onclick) {
|
1356 |
case 'lightbox':
|
1357 |
+
{
|
1358 |
+
onclick = "onclick=wdi_feed_" + currentFeed.feed_row.wdi_feed_counter + ".galleryBox('<%=id%>')";
|
1359 |
+
break;
|
1360 |
+
}
|
1361 |
case 'instagram':
|
1362 |
+
{
|
1363 |
+
onclick = 'onclick="window.open (\'<%= link%>\',\'_blank\')"';
|
1364 |
+
overlayCustomClass = 'wdi_hover_off';
|
1365 |
+
thumbClass = '';
|
1366 |
+
break;
|
1367 |
+
}
|
1368 |
case 'none':
|
1369 |
+
{
|
1370 |
+
onclick = '';
|
1371 |
+
overlayCustomClass = 'wdi_cursor_off wdi_hover_off';
|
1372 |
+
thumbClass = '';
|
1373 |
+
}
|
1374 |
}
|
1375 |
var wdi_feed_counter = currentFeed.feed_row['wdi_feed_counter'];
|
1376 |
var source = '<div class="wdi_feed_item ' + customClass + '" wdi_index=<%= wdi_index%> wdi_res_index=<%= wdi_res_index%> ' + pagination + ' wdi_type="image" id="wdi_' + wdi_feed_counter + '_<%=id%>">' +
|
1377 |
'<div class="wdi_photo_wrap">' +
|
1378 |
'<div class="wdi_photo_wrap_inner">' +
|
1379 |
'<div class="wdi_photo_img">' +
|
1380 |
+
'<img class="wdi_img" ' + sourceAttr + '="<%=image_url%>" alt="feed_image" onerror="wdi_front.brokenImageHandler(this);">' +
|
1381 |
'<div class="wdi_photo_overlay ' + overlayCustomClass + '" >' + showUsernameOnThumb +
|
1382 |
'<div class="wdi_thumb_icon" ' + onclick + ' style="display:table;width:100%;height:100%;">' +
|
1383 |
'<div style="display:table-cell;vertical-align:middle;text-align:center;color:white;">' +
|
1398 |
}
|
1399 |
source += '<div class="clear"></div>';
|
1400 |
if (currentFeed['feed_row']['show_description'] === '1') {
|
1401 |
+
source += '<div class="wdi_photo_title" onclick=' + onclickevent + ' >' +
|
1402 |
'<%=caption%>' +
|
1403 |
'</div>';
|
1404 |
}
|
1410 |
return template;
|
1411 |
}
|
1412 |
|
1413 |
+
wdi_front.replaceToVideo = function (url, index, feed_counter)
|
1414 |
+
{
|
1415 |
|
1416 |
overlayHtml = "<video style='width:auto !important; height:auto !important; max-width:100% !important; max-height:100% !important; margin:0 !important;' controls=''>" +
|
1417 |
"<source src='" + url + "' type='video/mp4'>" +
|
1424 |
/*
|
1425 |
* Template for all feed items which have type=video
|
1426 |
*/
|
1427 |
+
wdi_front.getVideoTemplate = function (currentFeed)
|
1428 |
+
{
|
1429 |
var page = wdi_front.setPage(currentFeed);
|
1430 |
var customClass = '';
|
1431 |
var pagination = '';
|
1439 |
if (page != '') {
|
1440 |
pagination = 'wdi_page="' + page + '"';
|
1441 |
sourceAttr = 'src';
|
1442 |
+
} else {
|
1443 |
sourceAttr = 'src';
|
1444 |
}
|
1445 |
if (page != '' && page != 1) {
|
1446 |
customClass = 'wdi_hidden';
|
1447 |
}
|
1448 |
|
1449 |
+
if (currentFeed.feed_row.show_username_on_thumb == '1') {
|
1450 |
showUsernameOnThumb = '<span class="wdi_media_user">@<%= wdi_username%></span>';
|
1451 |
}
|
1452 |
|
1457 |
}
|
1458 |
|
1459 |
var onclickevent = "";
|
1460 |
+
if (currentFeed.feed_row.feed_type !== "blog_style") {
|
1461 |
+
if (currentFeed.feed_row.feed_type == 'masonry') {
|
1462 |
+
onclickevent = "wdi_responsive.showMasonryCaption(jQuery(this)," + currentFeed.feed_row.wdi_feed_counter + ");"
|
1463 |
+
} else {
|
1464 |
+
onclickevent = "wdi_responsive.showCaption(jQuery(this)," + currentFeed.feed_row.wdi_feed_counter + ");";
|
1465 |
}
|
1466 |
|
1467 |
}
|
1469 |
//creating onclick string for different options
|
1470 |
switch (currentFeed.feed_row.feed_item_onclick) {
|
1471 |
case 'lightbox':
|
1472 |
+
{
|
1473 |
+
onclick = "onclick=wdi_feed_" + currentFeed.feed_row.wdi_feed_counter + ".galleryBox('<%=id%>')";
|
1474 |
+
break;
|
1475 |
+
}
|
1476 |
case 'instagram':
|
1477 |
+
{
|
1478 |
+
onclick = 'onclick="window.open (\'<%= link%>\',\'_blank\')"';
|
1479 |
+
overlayCustomClass = 'wdi_hover_off';
|
1480 |
+
thumbClass = 'fa-play';
|
1481 |
+
break;
|
1482 |
+
}
|
1483 |
case 'none':
|
1484 |
+
{
|
1485 |
+
overlayCustomClass = 'wdi_cursor_off wdi_hover_off';
|
1486 |
+
thumbClass = '';
|
1487 |
+
if (currentFeed.feed_row.feed_type == 'blog_style' || currentFeed.feed_row.feed_type == 'image_browser') {
|
1488 |
+
onclick = "onclick=wdi_front.replaceToVideo('<%= video_url%>','<%= wdi_index%>'," + currentFeed.feed_row.wdi_feed_counter + ")";
|
1489 |
+
overlayCustomClass = '';
|
1490 |
+
thumbClass = 'fa-play';
|
|
|
1491 |
}
|
1492 |
+
}
|
1493 |
}
|
1494 |
|
1495 |
|
1498 |
'<div class="wdi_photo_wrap">' +
|
1499 |
'<div class="wdi_photo_wrap_inner">' +
|
1500 |
'<div class="wdi_photo_img">' +
|
1501 |
+
'<img class="wdi_img" ' + sourceAttr + '="<%=image_url%>" alt="feed_image" onerror="wdi_front.brokenImageHandler(this);">' +
|
1502 |
+
'<div class="wdi_photo_overlay ' + overlayCustomClass + '" ' + onclick + '>' + showUsernameOnThumb +
|
1503 |
'<div class="wdi_thumb_icon" style="display:table;width:100%;height:100%;">' +
|
1504 |
'<div style="display:table-cell;vertical-align:middle;text-align:center;color:white;">' +
|
1505 |
'<i class="fa ' + thumbClass + '"></i>' +
|
1519 |
}
|
1520 |
source += '<div class="clear"></div>';
|
1521 |
if (currentFeed['feed_row']['show_description'] === '1') {
|
1522 |
+
source += '<div class="wdi_photo_title" onclick=' + onclickevent + ' >' +
|
1523 |
'<%=caption%>' +
|
1524 |
'</div>';
|
1525 |
}
|
1530 |
return template;
|
1531 |
}
|
1532 |
|
1533 |
+
wdi_front.bindEvents = function (currentFeed)
|
1534 |
+
{
|
1535 |
if (currentFeed.feed_row.feed_display_view == 'load_more_btn') {
|
1536 |
//binding load more event
|
1537 |
+
jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' .wdi_load_more_container').on(wdi_front.clickOrTouch, function ()
|
1538 |
+
{
|
1539 |
//do the actual load more operation
|
1540 |
wdi_front.loadMore(jQuery(this).find('.wdi_load_more_wrap'));
|
1541 |
+
|
1542 |
});
|
1543 |
}
|
1544 |
|
1545 |
if (currentFeed.feed_row.feed_display_view == 'pagination') {
|
1546 |
//binding pagination events
|
1547 |
+
jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_next').on(wdi_front.clickOrTouch, function ()
|
1548 |
+
{
|
1549 |
wdi_front.paginatorNext(jQuery(this), currentFeed);
|
1550 |
});
|
1551 |
+
jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_prev').on(wdi_front.clickOrTouch, function ()
|
1552 |
+
{
|
1553 |
wdi_front.paginatorPrev(jQuery(this), currentFeed);
|
1554 |
});
|
1555 |
+
jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_last_page').on(wdi_front.clickOrTouch, function ()
|
1556 |
+
{
|
1557 |
wdi_front.paginationLastPage(jQuery(this), currentFeed);
|
1558 |
});
|
1559 |
+
jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_first_page').on(wdi_front.clickOrTouch, function ()
|
1560 |
+
{
|
1561 |
wdi_front.paginationFirstPage(jQuery(this), currentFeed);
|
1562 |
});
|
1563 |
//setting pagiantion flags
|
1565 |
}
|
1566 |
if (currentFeed.feed_row.feed_display_view == 'infinite_scroll') {
|
1567 |
//binding infinite scroll Events
|
1568 |
+
jQuery(window).on('scroll', function ()
|
1569 |
+
{
|
1570 |
wdi_front.infiniteScroll(currentFeed);
|
1571 |
});
|
1572 |
//infinite scroll flags
|
1576 |
|
1577 |
}
|
1578 |
|
1579 |
+
wdi_front.infiniteScroll = function (currentFeed)
|
1580 |
+
{
|
1581 |
|
1582 |
if (jQuery(window).scrollTop() <= jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_infinite_scroll').offset().top) {
|
1583 |
if (currentFeed.infiniteScrollFlag === false && currentFeed.stopInfiniteScrollFlag == false) {
|
1584 |
currentFeed.infiniteScrollFlag = true;
|
1585 |
wdi_front.loadMore(jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_infinite_scroll'), currentFeed);
|
1586 |
+
} else
|
1587 |
+
if (currentFeed.stopInfiniteScrollFlag) {
|
1588 |
+
wdi_front.allImagesLoaded(currentFeed);
|
1589 |
+
}
|
1590 |
|
1591 |
}
|
1592 |
}
|
1593 |
|
1594 |
|
1595 |
+
wdi_front.paginationFirstPage = function (btn, currentFeed)
|
1596 |
+
{
|
1597 |
if (currentFeed.paginator == 1 || currentFeed.currentPage == 1) {
|
1598 |
btn.addClass('wdi_disabled');
|
1599 |
return;
|
1611 |
|
1612 |
}
|
1613 |
|
1614 |
+
wdi_front.paginationLastPage = function (btn, currentFeed)
|
1615 |
+
{
|
1616 |
if (currentFeed.paginator == 1 || currentFeed.currentPage == currentFeed.paginator) {
|
1617 |
return;
|
1618 |
}
|
1628 |
first_page_btn.removeClass('wdi_disabled');
|
1629 |
}
|
1630 |
|
1631 |
+
wdi_front.paginatorNext = function (btn, currentFeed)
|
1632 |
+
{
|
1633 |
var last_page_btn = btn.parent().find('#wdi_last_page');
|
1634 |
var first_page_btn = btn.parent().find('#wdi_first_page');
|
1635 |
currentFeed.paginatorNextFlag = true;
|
1639 |
wdi_front.loadMore(btn, currentFeed, number_of_photos);
|
1640 |
//on the last page don't show got to last page button
|
1641 |
last_page_btn.addClass('wdi_disabled');
|
1642 |
+
} else
|
|
|
|
|
|
|
1643 |
if (currentFeed.paginator > currentFeed.currentPage) {
|
1644 |
+
currentFeed.currentPage++;
|
1645 |
+
wdi_front.updatePagination(currentFeed, 'next');
|
1646 |
+
//check if new page isn't the last one then enable last page button
|
1647 |
+
if (currentFeed.paginator > currentFeed.currentPage) {
|
1648 |
+
last_page_btn.removeClass('wdi_disabled');
|
1649 |
+
} else {
|
1650 |
+
last_page_btn.addClass('wdi_disabled');
|
1651 |
+
}
|
1652 |
}
|
|
|
1653 |
|
1654 |
//enable first page button
|
1655 |
first_page_btn.removeClass('wdi_disabled');
|
1657 |
|
1658 |
}
|
1659 |
|
1660 |
+
wdi_front.paginatorPrev = function (btn, currentFeed)
|
1661 |
+
{
|
1662 |
var last_page_btn = btn.parent().find('#wdi_last_page');
|
1663 |
var first_page_btn = btn.parent().find('#wdi_first_page');
|
1664 |
if (currentFeed.currentPage == 1) {
|
1679 |
}
|
1680 |
|
1681 |
//displays proper images for specific page after pagination buttons click event
|
1682 |
+
wdi_front.updatePagination = function (currentFeed, dir, oldPage)
|
1683 |
+
{
|
1684 |
var currentFeedString = '#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'];
|
1685 |
+
jQuery(currentFeedString + ' [wdi_page="' + currentFeed.currentPage + '"]').each(function ()
|
1686 |
+
{
|
1687 |
jQuery(this).removeClass('wdi_hidden');
|
1688 |
});
|
1689 |
switch (dir) {
|
1690 |
case 'next':
|
1691 |
+
{
|
1692 |
+
var oldPage = currentFeed.currentPage - 1;
|
1693 |
+
jQuery(currentFeedString + ' .wdi_feed_wrapper').height(jQuery('.wdi_feed_wrapper').height());
|
1694 |
+
jQuery(currentFeedString + ' [wdi_page="' + oldPage + '"]').each(function ()
|
1695 |
{
|
1696 |
+
jQuery(this).addClass('wdi_hidden');
|
1697 |
+
});
|
1698 |
+
break;
|
1699 |
+
}
|
|
|
|
|
|
|
1700 |
case 'prev':
|
1701 |
+
{
|
1702 |
+
var oldPage = currentFeed.currentPage + 1;
|
1703 |
+
jQuery(currentFeedString + ' .wdi_feed_wrapper').height(jQuery('.wdi_feed_wrapper').height());
|
1704 |
+
jQuery(currentFeedString + ' [wdi_page="' + oldPage + '"]').each(function ()
|
1705 |
{
|
1706 |
+
jQuery(this).addClass('wdi_hidden');
|
1707 |
+
});
|
1708 |
+
break;
|
1709 |
+
}
|
1710 |
+
case 'custom':
|
1711 |
+
{
|
1712 |
+
var oldPage = oldPage;
|
1713 |
+
if (oldPage != currentFeed.currentPage) {
|
1714 |
jQuery(currentFeedString + ' .wdi_feed_wrapper').height(jQuery('.wdi_feed_wrapper').height());
|
1715 |
+
jQuery(currentFeedString + ' [wdi_page="' + oldPage + '"]').each(function ()
|
1716 |
+
{
|
1717 |
jQuery(this).addClass('wdi_hidden');
|
1718 |
});
|
|
|
1719 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1720 |
|
1721 |
+
break;
|
1722 |
+
}
|
1723 |
}
|
1724 |
currentFeed.paginatorNextFlag = false;
|
1725 |
|
1728 |
}
|
1729 |
|
1730 |
|
1731 |
+
wdi_front.loadMore = function (button, _currentFeed)
|
1732 |
+
{
|
1733 |
|
1734 |
|
1735 |
var dataCounter = 0;
|
1736 |
+
if (button != '' && typeof button != 'undefined' && button != 'initial' && button != 'initial-keep') {
|
1737 |
var currentFeed = window[button.parent().parent().parent().parent().attr('id')];
|
1738 |
}
|
1739 |
+
if (typeof _currentFeed != 'undefined') {
|
1740 |
var currentFeed = _currentFeed;
|
1741 |
}
|
1742 |
//check if any filter is enabled and filter user images has finished
|
1766 |
} else {
|
1767 |
currentFeed['auto_trigger'] = false;
|
1768 |
}
|
1769 |
+
//ading ajax loading
|
1770 |
wdi_front.ajaxLoader(currentFeed);
|
1771 |
|
1772 |
|
|
|
1773 |
//check if masonry view is on and and feed display type is pagination then
|
1774 |
//close all captions before loading more pages for porper pagination rendering
|
1775 |
if (currentFeed.feed_row.feed_type === 'masonry' && currentFeed.feed_row.feed_display_view == 'pagination') {
|
1776 |
+
jQuery('#wdi_feed_' + wdi_front.feed_counter + ' .wdi_full_caption').each(function ()
|
1777 |
+
{
|
1778 |
jQuery(this).find('.wdi_photo_title').trigger(wdi_front.clickOrTouch);
|
1779 |
});
|
1780 |
}
|
1781 |
|
1782 |
|
|
|
1783 |
//check if all data loaded then remove ajaxLoader
|
1784 |
for (var i = 0; i < currentFeed.usersData.length; i++) {
|
1785 |
if (currentFeed.usersData[i]['finished'] === 'finished') {
|
1800 |
|
1801 |
var pagination = usersData[i]['pagination'];
|
1802 |
var user = {
|
1803 |
+
user_id: usersData[i]['user_id'],
|
1804 |
+
username: usersData[i]['username']
|
1805 |
+
}
|
1806 |
+
|
1807 |
//checking if pagination url exists then load images, else skip
|
1808 |
+
if (pagination['next_url'] != '' && pagination['next_url'] != null && typeof pagination['next_url'] != 'undefined') {
|
1809 |
var next_url = pagination['next_url'];
|
1810 |
wdi_front.loadMoreRequest(user, next_url, currentFeed, button);
|
1811 |
} else {
|
1812 |
|
1813 |
if (button == 'initial-keep') {
|
|
|
1814 |
currentFeed.temproraryUsersData[i] = currentFeed.usersData[i];
|
1815 |
}
|
1816 |
currentFeed.loadMoreDataCount--;
|
1817 |
|
|
|
|
|
|
|
1818 |
|
1819 |
+
wdi_front.checkForLoadMoreDone(currentFeed, button);
|
1820 |
continue;
|
1821 |
}
|
1822 |
}
|
1827 |
/*
|
1828 |
* Requests images based on provided pagination url
|
1829 |
*/
|
1830 |
+
wdi_front.loadMoreRequest = function (user, next_url, currentFeed, button)
|
1831 |
+
{
|
1832 |
|
1833 |
var usersData = currentFeed['usersData'];
|
1834 |
var errorMessage = '';
|
1835 |
|
|
|
1836 |
currentFeed.instagram.requestByUrl(next_url, {
|
1837 |
+
success: function (response)
|
1838 |
+
{
|
1839 |
+
if (response === '' || typeof response == 'undefined' || response == null) {
|
1840 |
errorMessage = wdi_front_messages.network_error;
|
1841 |
currentFeed.loadMoreDataCount--;
|
1842 |
alert(errorMessage);
|
1861 |
}
|
1862 |
////////////////
|
1863 |
/*if button is initial-keep then we will lose currentFeed['usersData'][i]
|
1864 |
+
for not loosing it we keep it in currentFeed.temproraryUsersData, which value will be
|
1865 |
+
used later in wdi_front.checkForLoadMoreDone(), in other cases when button is set to
|
1866 |
+
initial we already keep data in that variable, so we don't deed to keep it again, it will give us duplicate value
|
1867 |
+
*/
|
1868 |
+
|
1869 |
if (button == 'initial-keep') {
|
1870 |
currentFeed.temproraryUsersData[i] = currentFeed.usersData[i];
|
1871 |
}
|
1882 |
|
1883 |
}
|
1884 |
|
1885 |
+
wdi_front.checkForLoadMoreDone = function (currentFeed, button)
|
1886 |
+
{
|
1887 |
var load_more_number = currentFeed.feed_row['load_more_number'];
|
1888 |
var number_of_photos = currentFeed.feed_row['number_of_photos'];
|
1889 |
|
1891 |
|
1892 |
currentFeed.temproraryUsersData = wdi_front.mergeData(currentFeed.temproraryUsersData, currentFeed.usersData);
|
1893 |
var gettedDataLength = wdi_front.getArrayContentLength(currentFeed.temproraryUsersData, 'data');
|
1894 |
+
/*this will happen when we call loadMore first time
|
1895 |
+
initial-keep is the same as initial except that if loadMore is called
|
1896 |
+
with initial-keep we store data on currentFeed.temproraryUsersData before checkLoadMoreDone()
|
1897 |
+
function call*/
|
1898 |
if (button == 'initial-keep') {
|
1899 |
button = 'initial';
|
1900 |
}
|
1901 |
//if button is set to inital load number_of_photos photos
|
1902 |
if (button == 'initial') {
|
1903 |
+
|
1904 |
/*if existing data length is smaller then load_more_number then get more objects until desired number is reached
|
1905 |
also if it is not possible to reach the desired number (this will happen when all users has no more photos) then
|
1906 |
displayFeed()*/
|
1911 |
} else {
|
1912 |
|
1913 |
currentFeed.usersData = currentFeed.temproraryUsersData;
|
1914 |
+
|
1915 |
wdi_front.displayFeed(currentFeed);
|
1916 |
//when all data us properly displayed check for any active filters and then apply them
|
1917 |
wdi_front.applyFilters(currentFeed);
|
1919 |
//resetting temprorary users data array for the next loadmoer call
|
1920 |
currentFeed.temproraryUsersData = [];
|
1921 |
|
1922 |
+
|
1923 |
}
|
1924 |
|
1925 |
} else {
|
1933 |
|
1934 |
currentFeed.usersData = currentFeed.temproraryUsersData;
|
1935 |
|
1936 |
+
if (!wdi_front.activeUsersCount(currentFeed)) {
|
1937 |
return;
|
1938 |
+
}
|
1939 |
|
|
|
1940 |
wdi_front.displayFeed(currentFeed, load_more_number);
|
1941 |
//when all data us properly displayed check for any active filters and then apply them
|
1942 |
wdi_front.applyFilters(currentFeed);
|
1947 |
}
|
1948 |
|
1949 |
|
|
|
1950 |
}
|
1951 |
}
|
1952 |
|
1953 |
+
wdi_front.allDataHasFinished = function (currentFeed)
|
1954 |
+
{
|
1955 |
var c = 0;
|
1956 |
+
for (var j = 0; j < currentFeed.dataStorageRaw.length; j++) {
|
1957 |
+
if (currentFeed.dataStorageRaw[j].length() == 0 && currentFeed.dataStorageRaw[j].locked == true) {
|
1958 |
c++;
|
1959 |
}
|
1960 |
}
|
1963 |
}
|
1964 |
|
1965 |
|
1966 |
+
wdi_front.mergeData = function (array1, array2)
|
1967 |
+
{
|
1968 |
|
1969 |
|
1970 |
for (var i = 0; i < array2.length; i++) {
|
1971 |
+
if (typeof array1[i] != 'undefined') {
|
1972 |
if (array2[i]['finished'] == 'finished') {
|
1973 |
continue;
|
1974 |
}
|
1975 |
+
|
1976 |
//if user data is finished then dont add duplicate data
|
1977 |
+
if (typeof array1[i]['pagination']['next_max_id'] == 'undefined' &&
|
1978 |
+
typeof array1[i]['pagination']['next_max_like_id'] == 'undefined') {
|
1979 |
continue;
|
1980 |
}
|
1981 |
//extend data
|
1992 |
}
|
1993 |
|
1994 |
|
|
|
1995 |
//broken image handling
|
1996 |
+
wdi_front.brokenImageHandler = function (source)
|
1997 |
+
{
|
1998 |
source.src = wdi_url.plugin_url + "../images/missing.png";
|
1999 |
source.onerror = "";
|
2000 |
return true;
|
2003 |
|
2004 |
|
2005 |
//ajax loading
|
2006 |
+
wdi_front.ajaxLoader = function (currentFeed)
|
2007 |
+
{
|
2008 |
var wdi_feed_counter = currentFeed.feed_row['wdi_feed_counter'];
|
2009 |
|
2010 |
var feed_container = jQuery('#wdi_feed_' + wdi_feed_counter);
|
2025 |
}
|
2026 |
|
2027 |
|
|
|
2028 |
////////////////////////////////////////////////////
|
2029 |
|
2030 |
}
|
2031 |
|
2032 |
//if all images loaded then clicking load more causes it's removal
|
2033 |
+
wdi_front.allImagesLoaded = function (currentFeed)
|
2034 |
+
{
|
2035 |
////////////////////////////////////////////////////////////////////
|
2036 |
|
2037 |
//clearInterval(currentFeed.loadingInterval);
|
2054 |
}
|
2055 |
|
2056 |
|
|
|
|
|
2057 |
//custom event fired for user based custom js
|
2058 |
feed_container.trigger('wdi_feed_loaded');
|
2059 |
|
2062 |
|
2063 |
|
2064 |
//shows different parts of the feed based user choice
|
2065 |
+
wdi_front.show = function (name, currentFeed)
|
2066 |
+
{
|
2067 |
var wdi_feed_counter = currentFeed.feed_row['wdi_feed_counter'];
|
2068 |
var feed_container = jQuery('#wdi_feed_' + wdi_feed_counter + ' .wdi_feed_container');
|
2069 |
var _this = this;
|
2070 |
switch (name) {
|
2071 |
case 'header':
|
2072 |
+
{
|
2073 |
+
show_header();
|
2074 |
+
break;
|
2075 |
+
}
|
2076 |
case 'users':
|
2077 |
+
{
|
2078 |
+
show_users(currentFeed);
|
2079 |
+
break;
|
2080 |
+
}
|
2081 |
|
2082 |
}
|
2083 |
|
2084 |
+
function show_header()
|
2085 |
+
{
|
2086 |
|
2087 |
var templateData = {
|
2088 |
'feed_thumb': currentFeed['feed_row']['feed_thumb'],
|
2096 |
feed_container.find('.wdi_feed_header').html(containerHtml + html);
|
2097 |
|
2098 |
|
|
|
2099 |
}
|
2100 |
|
2101 |
+
function show_users(currentFeed)
|
2102 |
+
{
|
2103 |
feed_container.find('.wdi_feed_users').html('');
|
2104 |
var users = currentFeed['feed_users'];
|
2105 |
var access_token = currentFeed['feed_row']['access_token'];
|
2107 |
currentFeed.headerUserinfo = [];
|
2108 |
getThumb();
|
2109 |
//recursively calls itself until all user data is ready then displyes it with escapeRequest
|
2110 |
+
function getThumb()
|
2111 |
+
{
|
2112 |
|
2113 |
if (currentFeed.headerUserinfo.length == users.length) {
|
2114 |
escapeRequest(currentFeed.headerUserinfo, currentFeed);
|
2115 |
return;
|
2116 |
}
|
2117 |
var _user = users[currentFeed.headerUserinfo.length];
|
2118 |
+
|
2119 |
+
|
2120 |
+
if (typeof _user === 'string' && _user === 'self') {
|
2121 |
+
currentFeed.instagram.getSelfInfo({
|
2122 |
+
success: function (response)
|
2123 |
{
|
2124 |
+
response = _this.checkMediaResponse(response);
|
2125 |
+
if (response != false) {
|
2126 |
+
var obj = {
|
2127 |
+
id: response['data']['id'],
|
2128 |
+
name: response['data']['username'],
|
2129 |
+
url: response['data']['profile_picture'],
|
2130 |
+
bio: response['data']['bio'],
|
2131 |
+
counts: response['data']['counts'],
|
2132 |
+
website: response['data']['website'],
|
2133 |
+
full_name: response['data']['full_name']
|
2134 |
+
}
|
2135 |
+
currentFeed.headerUserinfo.push(obj);
|
2136 |
+
i++;
|
2137 |
+
getThumb();
|
2138 |
+
}
|
2139 |
+
},
|
2140 |
+
args: {
|
2141 |
+
ignoreFiltering: true,
|
2142 |
+
}
|
2143 |
+
});
|
2144 |
+
}
|
2145 |
+
else
|
2146 |
+
if (_this.getInputType(_user.username) == 'hashtag') {
|
2147 |
+
currentFeed.instagram.getTagRecentMedia(_this.stripHashtag(_user.username), {
|
2148 |
+
success: function (response)
|
2149 |
+
{
|
2150 |
+
response = _this.checkMediaResponse(response);
|
2151 |
+
if (response != false) {
|
2152 |
|
2153 |
+
if (response['data'].length == 0) {
|
2154 |
+
thumb_img = '';
|
2155 |
+
} else {
|
2156 |
+
thumb_img = response['data'][0]['images']['thumbnail']['url'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2157 |
}
|
2158 |
+
var obj = {
|
2159 |
+
name: users[i]['username'],
|
2160 |
+
url: thumb_img,
|
2161 |
+
};
|
2162 |
+
i++;
|
2163 |
+
currentFeed.headerUserinfo.push(obj);
|
2164 |
+
getThumb();
|
2165 |
}
|
2166 |
+
},
|
2167 |
+
args: {
|
2168 |
+
ignoreFiltering: true,
|
2169 |
+
}
|
2170 |
+
});
|
2171 |
+
}
|
2172 |
+
else
|
2173 |
+
if (_this.getInputType(_user.username) == 'user') {
|
2174 |
currentFeed.instagram.getUserInfo(_user.id, {
|
2175 |
+
success: function (response)
|
2176 |
+
{
|
2177 |
response = _this.checkMediaResponse(response);
|
2178 |
if (response != false) {
|
2179 |
var obj = {
|
2190 |
getThumb();
|
2191 |
}
|
2192 |
},
|
2193 |
+
args: {
|
2194 |
+
ignoreFiltering: true,
|
2195 |
}
|
2196 |
+
});
|
|
|
2197 |
}
|
2198 |
+
|
2199 |
}
|
2200 |
+
|
2201 |
//when all user data is ready break recursion and create user elements
|
2202 |
+
function escapeRequest(info, currentFeed)
|
2203 |
+
{
|
2204 |
feed_container.find('.wdi_feed_users').html('');
|
2205 |
for (var k = 0; k < info.length; k++) {
|
2206 |
//setting all user filters to false
|
2234 |
feed_container.find('.wdi_feed_users').html(containerHtml + html);
|
2235 |
|
2236 |
|
|
|
2237 |
currentFeed.userSortFlags.push(userFilter);
|
2238 |
|
2239 |
var clearFloat = jQuery('<div class="clear"></div>');
|
2247 |
}
|
2248 |
|
2249 |
|
2250 |
+
wdi_front.getUserTemplate = function (currentFeed, username)
|
2251 |
+
{
|
2252 |
+
|
2253 |
var usersCount = currentFeed.feed_row.feed_users.split(',').length,
|
2254 |
instagramLink, instagramLinkOnClick, js;
|
2255 |
|
2256 |
switch (username[0]) {
|
2257 |
case '#':
|
2258 |
+
{
|
2259 |
+
instagramLink = '//instagram.com/explore/tags/' + username.substr(1, username.length);
|
2260 |
+
break;
|
2261 |
+
}
|
2262 |
default:
|
2263 |
+
{
|
2264 |
+
instagramLink = '//instagram.com/' + username;
|
2265 |
+
break;
|
2266 |
+
}
|
2267 |
}
|
2268 |
js = 'window.open("' + instagramLink + '","_blank")';
|
2269 |
instagramLinkOnClick = "onclick='" + js + "'";
|
2304 |
|
2305 |
if (usersCount == 1 && username[0] !== '#' && currentFeed.feed_row.display_user_info == '1') {
|
2306 |
source += '<div class="wdi_bio"><%= bio%></div>';
|
|
|
2307 |
|
2308 |
+
}
|
2309 |
|
2310 |
|
2311 |
source += '</div>' +
|
2312 |
'</div>';
|
2313 |
+
|
2314 |
var template = _.template(source);
|
2315 |
return template;
|
2316 |
}
|
2317 |
|
2318 |
|
2319 |
+
wdi_front.getHeaderTemplate = function ()
|
2320 |
+
{
|
2321 |
var source = '<div class="wdi_header_wrapper">' +
|
2322 |
'<div class="wdi_header_img_wrap">' +
|
2323 |
'<img src="<%=feed_thumb%>">' +
|
2331 |
|
2332 |
|
2333 |
//sets user filter to true and applys filter to feed
|
2334 |
+
wdi_front.addFilter = function (index, feed_counter)
|
2335 |
+
{
|
2336 |
var currentFeed = window['wdi_feed_' + feed_counter];
|
2337 |
var usersCount = currentFeed.feed_row.feed_users.split(',').length;
|
2338 |
if (usersCount < 2) {
|
2365 |
}
|
2366 |
|
2367 |
|
|
|
2368 |
if (currentFeed.feed_row.feed_display_view == 'pagination') {
|
2369 |
//reset responsive indexes because number of feed images may change after using filter
|
2370 |
currentFeed.resIndex = 0;
|
2396 |
}
|
2397 |
}
|
2398 |
|
2399 |
+
wdi_front.filterData = function (currentFeed)
|
2400 |
+
{
|
2401 |
|
2402 |
var users = currentFeed.userSortFlags;
|
2403 |
currentFeed.customFilteredData = [];
|
2412 |
|
2413 |
}
|
2414 |
|
2415 |
+
wdi_front.applyFilters = function (currentFeed)
|
2416 |
+
{
|
2417 |
for (var i = 0; i < currentFeed.userSortFlags.length; i++) {
|
2418 |
if (currentFeed.userSortFlags[i]['flag'] == true) {
|
2419 |
var userDiv = jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + '[user_index="' + i + '"]');
|
2425 |
}
|
2426 |
|
2427 |
//gets data Count from global storage
|
2428 |
+
wdi_front.getImgCount = function (currentFeed)
|
2429 |
+
{
|
2430 |
var dataStorage = currentFeed.dataStorage;
|
2431 |
var count = 0;
|
2432 |
for (var i = 0; i < dataStorage.length; i++) {
|
2436 |
}
|
2437 |
|
2438 |
//parses image data for lightbox popup
|
2439 |
+
wdi_front.parseLighboxData = function (currentFeed, filterFlag)
|
2440 |
+
{
|
2441 |
|
2442 |
var dataStorage = currentFeed.dataStorage;
|
2443 |
var sortImagesBy = currentFeed.feed_row['sort_images_by'];
|
2462 |
}
|
2463 |
|
2464 |
|
|
|
2465 |
for (i = 0; i < data.length; i++) {
|
2466 |
obj = {
|
2467 |
'alt': '',
|
2487 |
return popupData;
|
2488 |
}
|
2489 |
|
2490 |
+
wdi_front.convertUnixDate = function (date)
|
2491 |
+
{
|
2492 |
var utcSeconds = parseInt(date);
|
2493 |
var newDate = new Date(0);
|
2494 |
newDate.setUTCSeconds(utcSeconds);
|
2497 |
return str;
|
2498 |
}
|
2499 |
|
2500 |
+
wdi_front.getDescription = function (desc)
|
2501 |
+
{
|
2502 |
desc = desc.replace(/\r?\n|\r/g, ' ');
|
2503 |
|
2504 |
|
2505 |
return desc;
|
2506 |
}
|
2507 |
|
2508 |
+
wdi_front.getFileName = function (data)
|
2509 |
+
{
|
2510 |
var link = data['link'];
|
2511 |
var type = data['type'];
|
2512 |
if (type === 'image') {
|
2518 |
|
2519 |
}
|
2520 |
|
2521 |
+
wdi_front.getFileType = function (type)
|
2522 |
+
{
|
2523 |
if (type === 'image') {
|
2524 |
return "EMBED_OEMBED_INSTAGRAM_IMAGE";
|
2525 |
}
|
2529 |
}
|
2530 |
|
2531 |
|
2532 |
+
wdi_front.array_max = function (array)
|
2533 |
+
{
|
2534 |
var max = array[0];
|
2535 |
var minIndex = 0;
|
2536 |
for (var i = 1; i < array.length; i++) {
|
2545 |
};
|
2546 |
}
|
2547 |
|
2548 |
+
wdi_front.array_min = function (array)
|
2549 |
+
{
|
2550 |
var min = array[0];
|
2551 |
var minIndex = 0;
|
2552 |
for (var i = 1; i < array.length; i++) {
|
2564 |
/*
|
2565 |
* Returns users count whose feed is not finished
|
2566 |
*/
|
2567 |
+
wdi_front.activeUsersCount = function (currentFeed)
|
2568 |
+
{
|
2569 |
var counter = 0;
|
2570 |
for (var i = 0; i < currentFeed.usersData.length; i++) {
|
2571 |
if (currentFeed.usersData[i].finished != 'finished') {
|
2576 |
}
|
2577 |
|
2578 |
|
|
|
2579 |
/**
|
2580 |
* Return response if it is valid else returns boolean false
|
2581 |
* @param {Object} response [instagram API response]
|
2582 |
* @return {Object or Boolean} [false: if invalid response, object: if valid]
|
2583 |
*/
|
2584 |
+
wdi_front.checkMediaResponse = function (response)
|
2585 |
+
{
|
2586 |
|
2587 |
+
if (response == '' || typeof response == 'undefined' || response == null) {
|
2588 |
errorMessage = wdi_front_messages.connection_error;
|
2589 |
alert(errorMessage);
|
2590 |
return false;
|
2603 |
* @param {String} hashtag
|
2604 |
* @return {String}
|
2605 |
*/
|
2606 |
+
wdi_front.stripHashtag = function (hashtag)
|
2607 |
+
{
|
2608 |
switch (hashtag[0]) {
|
2609 |
case '#':
|
2610 |
+
{
|
2611 |
+
return hashtag.substr(1, hashtag.length);
|
2612 |
+
break;
|
2613 |
+
}
|
2614 |
default:
|
2615 |
+
{
|
2616 |
+
return hashtag;
|
2617 |
+
break;
|
2618 |
+
}
|
2619 |
}
|
2620 |
}
|
2621 |
|
2624 |
* @param {String} input [this is username or hashtag]
|
2625 |
* @return {String} [input type]
|
2626 |
*/
|
2627 |
+
wdi_front.getInputType = function (input)
|
2628 |
+
{
|
2629 |
+
|
2630 |
switch (input[0]) {
|
2631 |
case '#':
|
2632 |
+
{
|
2633 |
+
return 'hashtag';
|
2634 |
+
break;
|
2635 |
+
}
|
2636 |
case '%':
|
2637 |
+
{
|
2638 |
+
return 'location';
|
2639 |
+
break;
|
2640 |
+
}
|
2641 |
default:
|
2642 |
+
{
|
2643 |
+
return 'user';
|
2644 |
+
break;
|
2645 |
+
}
|
2646 |
|
2647 |
}
|
2648 |
}
|
2652 |
* or word is in the beggining or in the end of string
|
2653 |
* @param {String} captionText [String where search needs to be done]
|
2654 |
* @param {String} searchkey [word or phrazee to search]
|
2655 |
+
* @return {Boolean}
|
2656 |
*/
|
2657 |
+
wdi_front.regexpTestCaption = function (captionText, searchkey)
|
2658 |
+
{
|
2659 |
var flag1 = false,
|
2660 |
flag2 = false,
|
2661 |
matchIndexes = [],
|
2662 |
escKey = searchkey.replace(/[-[\]{}()*+?.,\\^$|]/g, "\\$&"),
|
2663 |
+
regexp1 = new RegExp("(?:^|\\s)" + escKey + "(?:^|\\s)"),
|
2664 |
+
regexp2 = new RegExp("(?:^|\\s)" + escKey, 'g');
|
2665 |
+
if (regexp1.exec(captionText) != null) {
|
2666 |
flag1 = true;
|
2667 |
}
|
2668 |
|
2669 |
+
while (( match = regexp2.exec(captionText) ) != null) {
|
2670 |
+
if (match.index == captionText.length - searchkey.length - 1) {
|
2671 |
+
flag2 = true;
|
2672 |
+
}
|
2673 |
}
|
2674 |
+
|
2675 |
+
if (flag1 == true || flag2 == true) {
|
2676 |
return true;
|
2677 |
+
} else {
|
2678 |
return false;
|
2679 |
}
|
2680 |
|
2681 |
}
|
2682 |
|
2683 |
|
|
|
2684 |
/**
|
2685 |
* replaces single new-lines with space
|
2686 |
* if multiple new lines are following each other then replaces all newlines with single space
|
2687 |
* @param {String} string [input string]
|
2688 |
* @return {String} [output string]
|
2689 |
*/
|
2690 |
+
wdi_front.replaceNewLines = function (string)
|
2691 |
+
{
|
2692 |
var delimeter = "vUkCJvN2ps3t",
|
2693 |
matchIndexes = [],
|
2694 |
regexp;
|
2695 |
+
string = string.replace(/\r?\n|\r/g, delimeter);
|
2696 |
|
2697 |
+
regexp = new RegExp(delimeter, 'g');
|
2698 |
+
while (( match = regexp.exec(string) ) != null) {
|
2699 |
+
matchIndexes.push(match.index);
|
2700 |
}
|
2701 |
|
2702 |
var pieces = string.split(delimeter);
|
2703 |
var foundFlag = 0;
|
2704 |
|
2705 |
+
for (var i = 0; i < pieces.length; i++) {
|
2706 |
+
|
2707 |
+
if (pieces[i] == '') {
|
2708 |
foundFlag++;
|
2709 |
+
} else {
|
2710 |
foundFlag = 0;
|
2711 |
}
|
2712 |
|
2713 |
+
if (foundFlag > 0) {
|
2714 |
+
pieces.splice(i, 1);
|
2715 |
foundFlag--;
|
2716 |
i--;
|
2717 |
}
|
2722 |
}
|
2723 |
|
2724 |
|
2725 |
+
wdi_front.isEmptyObject = function (obj)
|
2726 |
+
{
|
2727 |
+
for (var prop in obj) {
|
2728 |
+
if (obj.hasOwnProperty(prop))
|
2729 |
+
return false;
|
2730 |
+
}
|
2731 |
+
return true
|
2732 |
}
|
2733 |
|
2734 |
|
2735 |
+
var WDIFeed = function (obj)
|
2736 |
+
{
|
2737 |
this['data'] = obj['data']
|
2738 |
this['dataCount'] = obj['dataCount']
|
2739 |
this['feed_row'] = obj['feed_row']
|
2746 |
* @param {Object} args [some custom arguments ]
|
2747 |
* @return {Object} [instagram API response]
|
2748 |
*/
|
2749 |
+
WDIFeed.prototype.conditionalFilter = function (response, args)
|
2750 |
+
{
|
2751 |
|
2752 |
var currentFeed = this,
|
2753 |
conditional_filter_type = currentFeed.feed_row.conditional_filter_type,
|
2754 |
filters = currentFeed.feed_row.conditional_filters;
|
|
|
2755 |
|
|
|
2756 |
|
2757 |
+
if (args.ignoreFiltering == true) {
|
2758 |
+
|
2759 |
+
} else {
|
2760 |
+
|
2761 |
/**
|
2762 |
* Get rid of duplicate media
|
2763 |
*/
|
2764 |
+
response = this.avoidDuplicateMedia(response);
|
2765 |
}
|
|
|
2766 |
|
2767 |
+
|
2768 |
+
//if filters json is invalid then return response without filtering
|
2769 |
if (!wdi_front.isJsonString(filters)) {
|
2770 |
return response;
|
2771 |
} else {
|
2776 |
}
|
2777 |
|
2778 |
|
2779 |
+
if (currentFeed.feed_row.conditional_filter_enable == '0') {
|
2780 |
return response;
|
2781 |
}
|
2782 |
|
2783 |
+
|
2784 |
//console.log('filtering');
|
2785 |
//increase counter for determing request count if this counter is more then
|
2786 |
//currentFeed.maxConditionalFiltersRequestCount then program will terminate recursion loop
|
2788 |
|
2789 |
switch (conditional_filter_type) {
|
2790 |
case 'AND':
|
2791 |
+
{
|
2792 |
+
response = this.applyANDLogic(response, filters, currentFeed);
|
2793 |
+
break;
|
2794 |
+
}
|
2795 |
case 'OR':
|
2796 |
+
{
|
2797 |
+
response = this.applyORLogic(response, filters, currentFeed)
|
2798 |
+
break;
|
2799 |
+
}
|
2800 |
case 'NOR':
|
2801 |
+
{
|
2802 |
+
response = this.applyNORLogic(response, filters, currentFeed)
|
2803 |
+
break;
|
2804 |
+
}
|
2805 |
default:
|
2806 |
+
{
|
2807 |
+
break;
|
2808 |
+
}
|
2809 |
}
|
2810 |
|
2811 |
|
2813 |
}
|
2814 |
|
2815 |
|
|
|
2816 |
/**
|
2817 |
* Return those elements which meet filters conditions
|
2818 |
* @param {Object} response [instagram API response]
|
2819 |
* @param {Array} filters [Array of filter objects]
|
2820 |
* @return {Object} [filtered response]
|
2821 |
*/
|
2822 |
+
WDIFeed.prototype.applyANDLogic = function (response, filters)
|
2823 |
+
{
|
2824 |
var currentFeed = this;
|
2825 |
for (var i = 0; i < filters.length; i++) {
|
2826 |
response = this.filterResponse(response, filters[i]);
|
2835 |
* @param {Array} filters [Array of filter objects]
|
2836 |
* @return {Object} [filtered response]
|
2837 |
*/
|
2838 |
+
WDIFeed.prototype.applyORLogic = function (response, filters)
|
2839 |
+
{
|
2840 |
var currentFeed = this;
|
2841 |
var allData = [],
|
2842 |
res,
|
2866 |
}
|
2867 |
|
2868 |
|
|
|
2869 |
/**
|
2870 |
* Return those elements which meet filters conditions
|
2871 |
* @param {Object} response [instagram API response]
|
2872 |
* @param {Array} filters [Array of filter objects]
|
2873 |
* @return {Object} [filtered response]
|
2874 |
*/
|
2875 |
+
WDIFeed.prototype.applyNORLogic = function (response, filters)
|
2876 |
+
{
|
2877 |
|
2878 |
var res = response,
|
2879 |
currentFeed = this,
|
2880 |
matchedData = this.applyORLogic(response, filters, currentFeed),
|
2881 |
mergedData = [],
|
2882 |
returnObject;
|
2883 |
+
|
2884 |
for (var i = 0; i < res['data'].length; i++) {
|
2885 |
if (!this.mediaExists(res['data'][i], matchedData['data'])) {
|
2886 |
mergedData.push(res['data'][i]);
|
2896 |
}
|
2897 |
|
2898 |
|
2899 |
+
WDIFeed.prototype.mediaExists = function (media, array)
|
2900 |
+
{
|
2901 |
+
|
2902 |
for (var i = 0; i < array.length; i++) {
|
2903 |
if (media['id'] == array[i]['id']) {
|
2904 |
return true;
|
2914 |
* @param {Object} filter [filter object created in backend]
|
2915 |
* @return {Object} [filtered response]
|
2916 |
*/
|
2917 |
+
WDIFeed.prototype.filterResponse = function (response, filter)
|
2918 |
+
{
|
2919 |
|
2920 |
switch (filter.filter_type) {
|
2921 |
case 'hashtag':
|
2922 |
+
{
|
2923 |
+
return this.filterByHashtag(response, filter);
|
2924 |
+
break;
|
2925 |
+
}
|
2926 |
case 'username':
|
2927 |
+
{
|
2928 |
+
return this.filterByUsername(response, filter);
|
2929 |
+
break;
|
2930 |
+
}
|
2931 |
case 'mention':
|
2932 |
+
{
|
2933 |
+
return this.filterByMention(response, filter);
|
2934 |
+
break;
|
2935 |
+
}
|
2936 |
case 'description':
|
2937 |
+
{
|
2938 |
+
return this.filterByDescription(response, filter);
|
2939 |
+
break;
|
2940 |
+
}
|
2941 |
case 'location':
|
2942 |
+
{
|
2943 |
+
return this.filterByLocation(response, filter);
|
2944 |
+
break;
|
2945 |
+
}
|
2946 |
case 'url':
|
2947 |
+
{
|
2948 |
+
return this.filterByUrl(response, filter);
|
2949 |
+
break;
|
2950 |
+
}
|
2951 |
}
|
2952 |
}
|
2953 |
|
2954 |
|
|
|
2955 |
/**
|
2956 |
* filters data by given hastag filter and returns filtered response
|
2957 |
* @param {Object} response [instagram API response]
|
2958 |
* @param {Object} filter [hashtag filter object]
|
2959 |
* @return {Object} [filtered response]
|
2960 |
*/
|
2961 |
+
WDIFeed.prototype.filterByHashtag = function (response, filter)
|
2962 |
+
{
|
2963 |
var filteredResponse = [],
|
2964 |
currentTag,
|
2965 |
media,
|
2991 |
* @param {Object} filter [hashtag filter object]
|
2992 |
* @return {Object} [filtered response]
|
2993 |
*/
|
2994 |
+
WDIFeed.prototype.filterByUsername = function (response, filter)
|
2995 |
+
{
|
2996 |
var filteredResponse = [],
|
2997 |
media,
|
2998 |
returnObject;
|
3020 |
* @param {Object} filter [hashtag filter object]
|
3021 |
* @return {Object} [filtered response]
|
3022 |
*/
|
3023 |
+
WDIFeed.prototype.filterByMention = function (response, filter)
|
3024 |
+
{
|
3025 |
var filteredResponse = [],
|
3026 |
media, captionText, returnObject;
|
3027 |
for (var i = 0; i < response['data'].length; i++) {
|
3050 |
* @param {Object} filter [hashtag filter object]
|
3051 |
* @return {Object} [filtered response]
|
3052 |
*/
|
3053 |
+
WDIFeed.prototype.filterByDescription = function (response, filter)
|
3054 |
+
{
|
3055 |
var filteredResponse = [],
|
3056 |
media, captionText, returnObject;
|
3057 |
|
3058 |
for (var i = 0; i < response['data'].length; i++) {
|
3059 |
media = response['data'][i];
|
3060 |
if (media['caption'] !== null) {
|
3061 |
+
|
3062 |
captionText = media['caption']['text'].toLowerCase();
|
3063 |
+
captionText = wdi_front.replaceNewLines(captionText);
|
3064 |
var searchkey = filter.filter_by.toLowerCase();
|
3065 |
+
|
3066 |
+
if (wdi_front.regexpTestCaption(captionText, searchkey)) {
|
3067 |
filteredResponse.push(media);
|
3068 |
}
|
3069 |
}
|
3070 |
}
|
3071 |
+
|
3072 |
returnObject = {
|
3073 |
data: filteredResponse,
|
3074 |
meta: response['meta'],
|
3078 |
return returnObject;
|
3079 |
}
|
3080 |
|
|
|
3081 |
|
3082 |
/**
|
3083 |
* filters data by given location filter and returns filtered response
|
3085 |
* @param {Object} filter [hashtag filter object]
|
3086 |
* @return {Object} [filtered response]
|
3087 |
*/
|
3088 |
+
WDIFeed.prototype.filterByLocation = function (response, filter)
|
3089 |
+
{
|
3090 |
var filteredResponse = [],
|
3091 |
media, locationId, returnObject;
|
3092 |
for (var i = 0; i < response['data'].length; i++) {
|
3116 |
* @return {Object} [filtered response]
|
3117 |
*/
|
3118 |
|
3119 |
+
WDIFeed.prototype.filterByUrl = function (response, filter)
|
3120 |
+
{
|
3121 |
var filteredResponse = [],
|
3122 |
media, id, returnObject, filter_by;
|
3123 |
|
3145 |
/**
|
3146 |
* gets id of media from url, this id is not the one which comes with api request
|
3147 |
* @param {String} url [media url]
|
3148 |
+
* @return {String}
|
3149 |
*/
|
3150 |
+
WDIFeed.prototype.getIdFromUrl = function (url)
|
3151 |
+
{
|
3152 |
var url_parts = url.split('/'),
|
3153 |
id = false;
|
3154 |
for (var i = 0; i < url_parts.length; i++) {
|
3158 |
break;
|
3159 |
}
|
3160 |
}
|
3161 |
+
}
|
3162 |
+
;
|
3163 |
return id;
|
3164 |
}
|
3165 |
|
3169 |
* @param {Object} response [Instagram API request]
|
3170 |
* @return {Object} [response]
|
3171 |
*/
|
3172 |
+
WDIFeed.prototype.avoidDuplicateMedia = function (response)
|
3173 |
+
{
|
3174 |
var data = response['data'],
|
3175 |
uniqueData = [],
|
3176 |
returnObject = {};
|
3177 |
|
3178 |
+
for (var i = 0; i < data.length; i++) {
|
3179 |
+
if (!this.mediaExists(data[i], this.dataStorageList) && !this.mediaExists(data[i], uniqueData) && !this.mediaExists(data[i], this.conditionalFilterBuffer)) {
|
3180 |
+
uniqueData.push(data[i]);
|
3181 |
}
|
3182 |
}
|
3183 |
|
3188 |
meta: response['meta'],
|
3189 |
pagination: response['pagination']
|
3190 |
}
|
3191 |
+
|
3192 |
return returnObject;
|
3193 |
|
3194 |
}
|
3195 |
|
3196 |
|
3197 |
/* stores data from objects array into global variable */
|
3198 |
+
WDIFeed.prototype.storeRawData = function (objects, variable)
|
3199 |
+
{
|
3200 |
var _this = this;
|
3201 |
+
if (typeof this[variable] == "object" && typeof this[variable].length == "number") {
|
3202 |
//checks if in golbal storage user already exisit then it adds new data to user old data
|
3203 |
//else it simple puches new user with it's data to global storage
|
3204 |
+
for (var i = 0; i < objects.length; i++) {
|
3205 |
+
|
3206 |
|
|
|
3207 |
var hash_id = "";
|
3208 |
+
if (wdi_front.isHashtag(objects[i].user_id)) {
|
|
|
3209 |
hash_id = objects[i].pagination.next_max_tag_id;
|
|
|
|
|
|
|
|
|
|
|
3210 |
}
|
3211 |
+
else
|
3212 |
+
if (_this.feed_row.liked_feed == 'liked') {
|
3213 |
+
hash_id = objects[i].pagination.next_max_like_id;
|
3214 |
+
if (typeof hash_id == "undefined") {
|
3215 |
+
hash_id = "";
|
3216 |
+
}
|
3217 |
+
}
|
3218 |
+
else {
|
3219 |
+
hash_id = objects[i].pagination.next_max_id;
|
3220 |
+
if (typeof hash_id == "undefined") {
|
3221 |
+
hash_id = "";
|
3222 |
+
}
|
3223 |
+
}
|
3224 |
|
3225 |
+
if (typeof this[variable][i] == "undefined") {
|
3226 |
+
this[variable].push({
|
3227 |
+
data: objects[i].data,
|
3228 |
index: 0,
|
3229 |
locked: false,
|
3230 |
hash_id: hash_id,
|
3231 |
usersDataFinished: false,
|
3232 |
+
userId: objects[i].user_id,
|
3233 |
+
length: function ()
|
3234 |
+
{
|
3235 |
return this.data.length - this.index;
|
3236 |
},
|
3237 |
+
getData: function (num)
|
3238 |
+
{
|
3239 |
+
var data = this.data.slice(this.index, this.index + num);
|
3240 |
+
this.index += Math.min(num, this.length());
|
3241 |
+
|
3242 |
+
if (this.index == this.data.length && this.locked == true && this.usersDataFinished == false) {
|
3243 |
+
|
3244 |
+
for (var j = 0; j < _this.usersData.length; j++) {
|
3245 |
+
if (_this.usersData[j]['user_id'] == this.userId) {
|
3246 |
_this.usersData[j].finished = "finished";
|
3247 |
this.usersDataFinished = true;
|
3248 |
+
break;
|
3249 |
}
|
3250 |
}
|
3251 |
}
|
3252 |
return data;
|
3253 |
}
|
3254 |
+
});
|
3255 |
+
} else {
|
3256 |
+
if (this[variable][i].locked == false) {
|
3257 |
+
|
3258 |
+
if (hash_id != this[variable][i].hash_id) {
|
3259 |
+
this[variable][i].data = this[variable][i].data.concat(objects[i].data);
|
3260 |
this[variable][i].hash_id = hash_id;
|
3261 |
+
} else {
|
3262 |
this[variable][i].locked = true;
|
3263 |
+
|
3264 |
}
|
3265 |
}
|
3266 |
|
3271 |
}
|
3272 |
|
3273 |
|
3274 |
+
wdi_front.updateUsersIfNecessary = function (currentFeed)
|
3275 |
+
{
|
3276 |
var users = currentFeed.feed_users;
|
3277 |
var ifUpdateNecessary = false;
|
3278 |
|
3279 |
+
for (var i = 0; i < users.length; i++) {
|
3280 |
+
if ("#" == users[i].username.substr(0, 1)) {
|
3281 |
users[i].id = users[i].username;
|
3282 |
continue;
|
3283 |
}
|
3284 |
+
if ("" == users[i].id || 'username' == users[i].id) {
|
3285 |
|
3286 |
ifUpdateNecessary = true;
|
3287 |
+
currentFeed.instagram.searchForUsersByName(users[i].username, {
|
3288 |
+
success: function (res)
|
3289 |
+
{
|
3290 |
+
if (res.meta.code == 200 && res.data.length > 0) {
|
3291 |
|
3292 |
var found = false;
|
3293 |
+
|
3294 |
+
for (var k = 0; k < res.data.length; k++) {
|
3295 |
+
if (res.data[k].username == res.args.username) {
|
3296 |
found = true;
|
3297 |
break;
|
3298 |
}
|
3299 |
}
|
3300 |
|
3301 |
+
if (found) {
|
3302 |
+
for (var j = 0; j < users.length; j++) {
|
3303 |
+
if (res.data[k].username == users[j].username) {
|
3304 |
users[j].id = res.data[k].id;
|
3305 |
}
|
3306 |
}
|
3307 |
}
|
3308 |
|
3309 |
|
|
|
3310 |
}
|
3311 |
+
|
3312 |
var noid_user_left = false;
|
3313 |
+
for (var m = 0; m < users.length; m++) {
|
3314 |
+
if (users[m].id == "" || users[m].id == "username") {
|
3315 |
noid_user_left = true;
|
3316 |
break;
|
3317 |
}
|
3318 |
}
|
3319 |
+
if (!noid_user_left) {
|
3320 |
+
currentFeed.feed_row.feed_users = JSON.stringify(users);
|
3321 |
+
wdi_front.init(currentFeed);
|
3322 |
}
|
3323 |
+
|
3324 |
},
|
3325 |
+
username: users[i].username
|
3326 |
+
});
|
3327 |
}
|
3328 |
}
|
3329 |
|
3330 |
return ifUpdateNecessary;
|
3331 |
}
|
3332 |
|
3333 |
+
|
3334 |
+
|
3335 |
+
|
js/wdi_instagram.js
CHANGED
@@ -15,13 +15,13 @@
|
|
15 |
* searchForUsersByName = function( username, args ) : Get a list of users matching the query.
|
16 |
* searchForTagsByName = function(tagname, args) : Search for tags by name.
|
17 |
* getTagRecentMedia = function(tagname, args) : Gets recent media based on tagname
|
18 |
-
*
|
19 |
*/
|
20 |
|
21 |
|
22 |
|
23 |
/**
|
24 |
-
* example of arg
|
25 |
* @type {Object}
|
26 |
*/
|
27 |
// var args = {
|
@@ -38,7 +38,6 @@
|
|
38 |
// }
|
39 |
|
40 |
|
41 |
-
|
42 |
/**
|
43 |
* WDIInstagram object constructor
|
44 |
* @param {Object} args
|
@@ -47,12 +46,13 @@
|
|
47 |
* @param {Array} [args.filters] [array of object defining filters]
|
48 |
* @param {Object} [args.filters[i] ] [ filter object which contain 'where' : 'what' pair ]
|
49 |
* @param {String} [args.filters.filter[i].where] [name of function where filter must be applied]
|
50 |
-
* @param {String or Array} [args.filters.filter[i].what] [name of filtering function,
|
51 |
-
* if function is in global scope then it should be name of the funtion
|
52 |
-
* else if function in method of some object then it should be an array
|
53 |
* ['parent_object_name','filtering_function_name']]
|
54 |
*/
|
55 |
-
function WDIInstagram(args)
|
|
|
56 |
|
57 |
this.access_tokens = [];
|
58 |
this.filters = [];
|
@@ -73,19 +73,21 @@ function WDIInstagram(args) {
|
|
73 |
* @type {Object}
|
74 |
*/
|
75 |
this.statusCode = {
|
76 |
-
429
|
77 |
-
|
|
|
78 |
},
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
* gets filter function defined for specific method
|
83 |
* this function is internal function and cannot be called outside of this object
|
84 |
-
*
|
85 |
* @param {String} methodName [name of WDIInstagram method]
|
86 |
* @return {Function} [filtering function for {methodName}]
|
87 |
*/
|
88 |
-
this.getFilter = function(methodName)
|
|
|
89 |
var filters = _this.filters;
|
90 |
if (typeof filters == "undefined") {
|
91 |
return false;
|
@@ -100,21 +102,24 @@ function WDIInstagram(args) {
|
|
100 |
return window[filters[i].what[0]][filters[i].what[1]];
|
101 |
}
|
102 |
}
|
103 |
-
} else
|
104 |
-
if (typeof
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
|
|
|
|
112 |
}
|
113 |
}
|
114 |
return false;
|
115 |
}
|
116 |
|
117 |
-
function getAccessToken()
|
|
|
118 |
var access_tokens = _this.access_tokens,
|
119 |
index = parseInt(Math.random(0, 1) * access_tokens.length);
|
120 |
return access_tokens[index];
|
@@ -125,7 +130,8 @@ function WDIInstagram(args) {
|
|
125 |
* non string values are not allowed
|
126 |
* @param {String} token [Instagram API access token]
|
127 |
*/
|
128 |
-
this.addToken = function(token)
|
|
|
129 |
if (typeof token == 'string') {
|
130 |
_this.access_tokens.push(token);
|
131 |
}
|
@@ -156,11 +162,12 @@ function WDIInstagram(args) {
|
|
156 |
*
|
157 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
158 |
* or you can pass as callback function an anonymous function
|
159 |
-
*
|
160 |
*
|
161 |
* @return object of founded media
|
162 |
*/
|
163 |
-
this.getTagRecentMedia = function(tagname, args)
|
|
|
164 |
var instagram = this,
|
165 |
noArgument = false,
|
166 |
successFlag = false,
|
@@ -168,8 +175,8 @@ function WDIInstagram(args) {
|
|
168 |
errorFlag = false,
|
169 |
argFlag = false,
|
170 |
filter = this.getFilter('getTagRecentMedia'),
|
171 |
-
|
172 |
-
|
173 |
|
174 |
|
175 |
if (typeof args == 'undefined' || args.length === 0) {
|
@@ -179,16 +186,16 @@ function WDIInstagram(args) {
|
|
179 |
if ('success' in args) {
|
180 |
successFlag = true;
|
181 |
}
|
182 |
-
if(
|
183 |
statusCode = args['statusCode'];
|
184 |
}
|
185 |
if ('error' in args) {
|
186 |
errorFlag = true;
|
187 |
}
|
188 |
//
|
189 |
-
if (
|
190 |
argFlag = true;
|
191 |
-
}else{
|
192 |
args.args = {};
|
193 |
}
|
194 |
//
|
@@ -216,51 +223,57 @@ function WDIInstagram(args) {
|
|
216 |
type: 'POST',
|
217 |
url: baseUrl,
|
218 |
dataType: 'jsonp',
|
219 |
-
success: function(response)
|
220 |
-
|
|
|
221 |
|
222 |
if (successFlag) {
|
223 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
224 |
if (typeof window[args.success[0]] != 'undefined') {
|
225 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
226 |
if (filter) {
|
227 |
-
response = filter(response,instagram.filterArguments, args.args);
|
228 |
}
|
229 |
window[args.success[0]][args.success[1]](response);
|
230 |
}
|
231 |
}
|
232 |
|
233 |
-
} else
|
234 |
-
if (typeof
|
235 |
-
if (
|
236 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
}
|
238 |
-
window[args.success](response);
|
239 |
-
}
|
240 |
-
} else if (typeof args.success == 'function') {
|
241 |
-
if (filter) {
|
242 |
-
response = filter(response,instagram.filterArguments, args.args);
|
243 |
-
}
|
244 |
-
args.success(response);
|
245 |
-
}
|
246 |
}
|
247 |
},
|
248 |
-
error: function(response)
|
|
|
249 |
if (errorFlag) {
|
250 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
251 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
252 |
window[args['error'][0]][args['error'][1]](response);
|
253 |
}
|
254 |
-
} else
|
255 |
-
if (typeof
|
256 |
-
window[args['error']]
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
|
|
|
|
261 |
}
|
262 |
},
|
263 |
-
statusCode
|
264 |
});
|
265 |
|
266 |
}
|
@@ -284,17 +297,18 @@ function WDIInstagram(args) {
|
|
284 |
*
|
285 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
286 |
* or you can pass as callback function an anonymous function
|
287 |
-
*
|
288 |
*
|
289 |
* @return object of founded media
|
290 |
*/
|
291 |
|
292 |
-
this.searchForTagsByName = function(tagname, args)
|
|
|
293 |
var instagram = this,
|
294 |
noArgument = false,
|
295 |
successFlag = false,
|
296 |
statusCode = this.statusCode;
|
297 |
-
|
298 |
filter = this.getFilter('searchForTagsByName');
|
299 |
|
300 |
if (typeof args == 'undefined' || args.length === 0) {
|
@@ -306,7 +320,7 @@ function WDIInstagram(args) {
|
|
306 |
if ('error' in args) {
|
307 |
errorFlag = true;
|
308 |
}
|
309 |
-
if(
|
310 |
statusCode = args['statusCode'];
|
311 |
}
|
312 |
}
|
@@ -316,45 +330,51 @@ function WDIInstagram(args) {
|
|
316 |
type: 'POST',
|
317 |
url: 'https://api.instagram.com/v1/tags/search?q=' + tagname + '&access_token=' + getAccessToken(),
|
318 |
dataType: 'jsonp',
|
319 |
-
success: function(response)
|
|
|
320 |
if (successFlag) {
|
321 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
322 |
if (typeof window[args.success[0]] != 'undefined') {
|
323 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
324 |
if (filter) {
|
325 |
-
response = filter(response,instagram.filterArguments);
|
326 |
}
|
327 |
window[args.success[0]][args.success[1]](response);
|
328 |
}
|
329 |
}
|
330 |
-
} else
|
331 |
-
if (typeof
|
332 |
-
if (
|
333 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
334 |
}
|
335 |
-
window[args.success](response);
|
336 |
-
}
|
337 |
-
} else if (typeof args.success == 'function') {
|
338 |
-
if (filter) {
|
339 |
-
response = filter(response,instagram.filterArguments);
|
340 |
-
}
|
341 |
-
args.success(response);
|
342 |
-
}
|
343 |
}
|
344 |
},
|
345 |
-
error: function(response)
|
|
|
346 |
if (errorFlag) {
|
347 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
348 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
349 |
window[args['error'][0]][args['error'][1]](response);
|
350 |
}
|
351 |
-
} else
|
352 |
-
if (typeof
|
353 |
-
window[args['error']]
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
|
|
|
|
358 |
}
|
359 |
},
|
360 |
statusCode: statusCode
|
@@ -362,7 +382,6 @@ function WDIInstagram(args) {
|
|
362 |
}
|
363 |
|
364 |
|
365 |
-
|
366 |
/**
|
367 |
* Get a list of users matching the query.
|
368 |
*
|
@@ -370,7 +389,7 @@ function WDIInstagram(args) {
|
|
370 |
* @definition success_callback => which function to call in case of success
|
371 |
* @definition error_callback => which function to call in case of error
|
372 |
* @definition statusCode => StatusCode object.
|
373 |
-
*
|
374 |
* @param username
|
375 |
* @param args = {
|
376 |
* success: 'success_callback',
|
@@ -381,11 +400,12 @@ function WDIInstagram(args) {
|
|
381 |
*
|
382 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
383 |
* or you can pass as callback function an anonymous function
|
384 |
-
*
|
385 |
*
|
386 |
* @return object of founded users
|
387 |
*/
|
388 |
-
this.searchForUsersByName = function(username, args)
|
|
|
389 |
var instagram = this,
|
390 |
noArgument = false,
|
391 |
successFlag = false,
|
@@ -402,7 +422,7 @@ function WDIInstagram(args) {
|
|
402 |
if ('error' in args) {
|
403 |
errorFlag = true;
|
404 |
}
|
405 |
-
if(
|
406 |
statusCode = args['statusCode'];
|
407 |
}
|
408 |
}
|
@@ -412,64 +432,69 @@ function WDIInstagram(args) {
|
|
412 |
type: 'POST',
|
413 |
dataType: 'jsonp',
|
414 |
url: 'https://api.instagram.com/v1/users/search?q=' + username + '&access_token=' + getAccessToken(),
|
415 |
-
success: function(response)
|
|
|
416 |
if (successFlag) {
|
417 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
418 |
if (typeof window[args.success[0]] != 'undefined') {
|
419 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
420 |
if (filter) {
|
421 |
-
response = filter(response,instagram.filterArguments);
|
422 |
}
|
423 |
response.args = args;
|
424 |
window[args.success[0]][args.success[1]](response);
|
425 |
}
|
426 |
}
|
427 |
-
} else
|
428 |
-
if (typeof
|
429 |
-
if (
|
430 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
431 |
}
|
432 |
-
response.args = args;
|
433 |
-
window[args.success](response);
|
434 |
-
}
|
435 |
-
} else if (typeof args.success == 'function') {
|
436 |
-
if (filter) {
|
437 |
-
response = filter(response,instagram.filterArguments);
|
438 |
-
}
|
439 |
-
response.args = args;
|
440 |
-
args.success(response);
|
441 |
-
}
|
442 |
}
|
443 |
},
|
444 |
-
error: function(response)
|
|
|
445 |
if (errorFlag) {
|
446 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
447 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
448 |
window[args['error'][0]][args['error'][1]](response);
|
449 |
}
|
450 |
-
} else
|
451 |
-
if (typeof
|
452 |
-
window[args['error']]
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
|
|
|
|
457 |
}
|
458 |
},
|
459 |
-
statusCode
|
460 |
|
461 |
});
|
462 |
}
|
463 |
|
464 |
|
465 |
-
|
466 |
/**
|
467 |
* Get the list of recent media liked by the owner of the access_token.
|
468 |
*
|
469 |
*
|
470 |
* @definition success_callback => which function to call in case of success
|
471 |
* @definition error_callback => which function to call in case of error
|
472 |
-
* @definition statusCode => StatusCode object.
|
473 |
* @param args = {
|
474 |
* success: 'success_callback',
|
475 |
* error: 'error_callback',
|
@@ -479,18 +504,19 @@ function WDIInstagram(args) {
|
|
479 |
*
|
480 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
481 |
* or you can pass as callback function an anonymous function
|
482 |
-
*
|
483 |
*
|
484 |
* @return object of founded media
|
485 |
*/
|
486 |
|
487 |
-
this.getRecentLikedMedia = function(args)
|
|
|
488 |
var instagram = this,
|
489 |
noArgument = false,
|
490 |
successFlag = false,
|
491 |
statusCode = this.statusCode,
|
492 |
errorFlag = false,
|
493 |
-
filter = this.getFilter('getRecentLikedMedia')
|
|
|
494 |
|
495 |
if (typeof args == 'undefined' || args.length === 0) {
|
496 |
noArgument = true;
|
@@ -501,66 +527,93 @@ function WDIInstagram(args) {
|
|
501 |
if ('error' in args) {
|
502 |
errorFlag = true;
|
503 |
}
|
504 |
-
if(
|
505 |
statusCode = args['statusCode'];
|
506 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
507 |
}
|
508 |
|
509 |
|
510 |
jQuery.ajax({
|
511 |
type: 'POST',
|
512 |
dataType: 'jsonp',
|
513 |
-
url:
|
514 |
-
success: function(response)
|
|
|
515 |
if (successFlag) {
|
516 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
517 |
if (typeof window[args.success[0]] != 'undefined') {
|
518 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
519 |
if (filter) {
|
520 |
-
response = filter(response,instagram.filterArguments);
|
521 |
}
|
522 |
window[args.success[0]][args.success[1]](response);
|
523 |
}
|
524 |
}
|
525 |
-
} else
|
526 |
-
if (typeof
|
527 |
-
if (
|
528 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
529 |
}
|
530 |
-
window[args.success](response);
|
531 |
-
}
|
532 |
-
} else if (typeof args.success == 'function') {
|
533 |
-
if (filter) {
|
534 |
-
response = filter(response,instagram.filterArguments);
|
535 |
-
}
|
536 |
-
args.success(response);
|
537 |
-
}
|
538 |
}
|
539 |
},
|
540 |
-
error: function(response)
|
|
|
541 |
if (errorFlag) {
|
542 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
543 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
544 |
window[args['error'][0]][args['error'][1]](response);
|
545 |
}
|
546 |
-
} else
|
547 |
-
if (typeof
|
548 |
-
window[args['error']]
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
|
|
|
|
553 |
}
|
554 |
},
|
555 |
-
statusCode
|
556 |
|
557 |
});
|
558 |
}
|
559 |
|
560 |
|
561 |
-
|
562 |
/**
|
563 |
-
* Get the most recent media published by a user.
|
564 |
* This endpoint requires the public_content scope if the user-id is not the owner of the access_token.
|
565 |
*
|
566 |
*
|
@@ -570,7 +623,7 @@ function WDIInstagram(args) {
|
|
570 |
* @definition min_id => Return media before this min_id.
|
571 |
* @definition max_id => Return media after this max_id.
|
572 |
* @definition statusCode => StatusCode object.
|
573 |
-
*
|
574 |
* @param args = {
|
575 |
* success : 'success_callback',
|
576 |
* error : 'error_callback',
|
@@ -584,20 +637,23 @@ function WDIInstagram(args) {
|
|
584 |
*
|
585 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
586 |
* or you can pass as callback function an anonymous function
|
587 |
-
*
|
588 |
*
|
589 |
* @return object of founded media
|
590 |
*/
|
591 |
-
this.getUserRecentMedia = function(user_id, args)
|
|
|
592 |
var instagram = this,
|
593 |
noArgument = false,
|
594 |
successFlag = false,
|
595 |
argFlag = false,
|
596 |
-
|
597 |
statusCode = this.statusCode,
|
598 |
errorFlag = false,
|
599 |
filter = this.getFilter('getUserRecentMedia'),
|
600 |
baseUrl = 'https://api.instagram.com/v1/users/' + user_id + '/media/recent/?access_token=' + getAccessToken();
|
|
|
|
|
601 |
if (typeof args == 'undefined' || args.length === 0) {
|
602 |
noArgument = true;
|
603 |
} else {
|
@@ -605,13 +661,13 @@ function WDIInstagram(args) {
|
|
605 |
successFlag = true;
|
606 |
}
|
607 |
|
608 |
-
if(
|
609 |
statusCode = args['statusCode'];
|
610 |
}
|
611 |
-
|
612 |
-
if (
|
613 |
argFlag = true;
|
614 |
-
}else{
|
615 |
args.args = {};
|
616 |
}
|
617 |
|
@@ -644,47 +700,53 @@ function WDIInstagram(args) {
|
|
644 |
type: 'POST',
|
645 |
dataType: 'jsonp',
|
646 |
url: baseUrl,
|
647 |
-
success: function(response)
|
648 |
-
|
|
|
649 |
|
650 |
if (successFlag) {
|
651 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
652 |
if (typeof window[args.success[0]] != 'undefined') {
|
653 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
654 |
if (filter) {
|
655 |
-
response = filter(response,instagram.filterArguments, args.args);
|
656 |
}
|
657 |
window[args.success[0]][args.success[1]](response);
|
658 |
}
|
659 |
}
|
660 |
-
} else
|
661 |
-
if (typeof
|
662 |
-
if (
|
663 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
664 |
}
|
665 |
-
window[args.success](response);
|
666 |
-
}
|
667 |
-
} else if (typeof args.success == 'function') {
|
668 |
-
if (filter) {
|
669 |
-
response = filter(response,instagram.filterArguments, args.args);
|
670 |
-
}
|
671 |
-
args.success(response);
|
672 |
-
}
|
673 |
}
|
674 |
},
|
675 |
-
error: function(response)
|
|
|
676 |
if (errorFlag) {
|
677 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
678 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
679 |
window[args['error'][0]][args['error'][1]](response);
|
680 |
}
|
681 |
-
} else
|
682 |
-
if (typeof
|
683 |
-
window[args['error']]
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
|
|
|
|
688 |
}
|
689 |
},
|
690 |
statusCode: statusCode
|
@@ -694,7 +756,6 @@ function WDIInstagram(args) {
|
|
694 |
}
|
695 |
|
696 |
|
697 |
-
|
698 |
/**
|
699 |
* Get the most recent media published by the owner of the access_token.
|
700 |
*
|
@@ -705,7 +766,7 @@ function WDIInstagram(args) {
|
|
705 |
* @definition min_id => Return media before this min_id.
|
706 |
* @definition max_id => Return media after this max_id.
|
707 |
* @definition statusCode => StatusCode object.
|
708 |
-
*
|
709 |
* @param args = {
|
710 |
* success : 'success_callback',
|
711 |
* error : 'error_callback',
|
@@ -713,22 +774,23 @@ function WDIInstagram(args) {
|
|
713 |
* min_id : 'min_id'
|
714 |
* max_id : 'max_id'
|
715 |
* statusCode : statusCode
|
716 |
-
*
|
717 |
* }
|
718 |
*
|
719 |
*
|
720 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
721 |
* or you can pass as callback function an anonymous function
|
722 |
-
*
|
723 |
*
|
724 |
* @return object of founded media
|
725 |
*/
|
726 |
-
this.getSelfRecentMedia = function(args)
|
|
|
727 |
var instagram = this,
|
728 |
noArgument = false,
|
729 |
successFlag = false,
|
730 |
statusCode = this.statusCode;
|
731 |
-
|
732 |
filter = this.getFilter('getSelfRecentMedia'),
|
733 |
baseUrl = 'https://api.instagram.com/v1/users/self/media/recent/?access_token=' + getAccessToken();
|
734 |
|
@@ -743,7 +805,7 @@ function WDIInstagram(args) {
|
|
743 |
errorFlag = true;
|
744 |
}
|
745 |
|
746 |
-
if(
|
747 |
statusCode = args['statusCode'];
|
748 |
}
|
749 |
|
@@ -771,63 +833,68 @@ function WDIInstagram(args) {
|
|
771 |
type: 'POST',
|
772 |
dataType: 'jsonp',
|
773 |
url: baseUrl,
|
774 |
-
success: function(response)
|
|
|
775 |
if (successFlag) {
|
776 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
777 |
if (typeof window[args.success[0]] != 'undefined') {
|
778 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
779 |
if (filter) {
|
780 |
-
response = filter(response,instagram.filterArguments);
|
781 |
}
|
782 |
window[args.success[0]][args.success[1]](response);
|
783 |
}
|
784 |
}
|
785 |
-
} else
|
786 |
-
if (typeof
|
787 |
-
if (
|
788 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
789 |
}
|
790 |
-
window[args.success](response);
|
791 |
-
}
|
792 |
-
} else if (typeof args.success == 'function') {
|
793 |
-
if (filter) {
|
794 |
-
response = filter(response,instagram.filterArguments);
|
795 |
-
}
|
796 |
-
args.success(response);
|
797 |
-
}
|
798 |
}
|
799 |
},
|
800 |
-
error: function(response)
|
|
|
801 |
if (errorFlag) {
|
802 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
803 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
804 |
window[args['error'][0]][args['error'][1]](response);
|
805 |
}
|
806 |
-
} else
|
807 |
-
if (typeof
|
808 |
-
window[args['error']]
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
|
|
|
|
813 |
}
|
814 |
},
|
815 |
-
statusCode
|
816 |
|
817 |
});
|
818 |
}
|
819 |
|
820 |
|
821 |
-
|
822 |
/**
|
823 |
-
* Get information about a user.
|
824 |
* This endpoint requires the public_content scope if the user-id is not the owner of the access_token.
|
825 |
*
|
826 |
*
|
827 |
* @definition success_callback => which function to call in case of success
|
828 |
* @definition error_callback => which function to call in case of error
|
829 |
* @definition statusCode => StatusCode object.
|
830 |
-
*
|
831 |
* @param args = {
|
832 |
* success : 'success_callback',
|
833 |
* error : 'error_callback'
|
@@ -837,11 +904,12 @@ function WDIInstagram(args) {
|
|
837 |
*
|
838 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
839 |
* or you can pass as callback function an anonymous function
|
840 |
-
*
|
841 |
*
|
842 |
* @return object of founded info
|
843 |
*/
|
844 |
-
this.getUserInfo = function(user_id, args)
|
|
|
845 |
var instagram = this,
|
846 |
noArgument = false,
|
847 |
successFlag = false,
|
@@ -860,7 +928,7 @@ function WDIInstagram(args) {
|
|
860 |
errorFlag = true;
|
861 |
}
|
862 |
|
863 |
-
if(
|
864 |
statusCode = args['statusCode'];
|
865 |
}
|
866 |
}
|
@@ -868,54 +936,59 @@ function WDIInstagram(args) {
|
|
868 |
type: 'POST',
|
869 |
dataType: 'jsonp',
|
870 |
url: 'https://api.instagram.com/v1/users/' + user_id + '/?access_token=' + getAccessToken(),
|
871 |
-
success: function(response)
|
|
|
872 |
if (successFlag) {
|
873 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
874 |
if (typeof window[args.success[0]] != 'undefined') {
|
875 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
876 |
if (filter) {
|
877 |
-
response = filter(response,instagram.filterArguments);
|
878 |
}
|
879 |
window[args.success[0]][args.success[1]](response);
|
880 |
}
|
881 |
}
|
882 |
-
} else
|
883 |
-
if (typeof
|
884 |
-
if (
|
885 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
886 |
}
|
887 |
-
window[args.success](response);
|
888 |
-
}
|
889 |
-
} else if (typeof args.success == 'function') {
|
890 |
-
if (filter) {
|
891 |
-
response = filter(response,instagram.filterArguments);
|
892 |
-
}
|
893 |
-
args.success(response);
|
894 |
-
}
|
895 |
}
|
896 |
},
|
897 |
-
error: function(response)
|
|
|
898 |
if (errorFlag) {
|
899 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
900 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
901 |
window[args['error'][0]][args['error'][1]](response);
|
902 |
}
|
903 |
-
} else
|
904 |
-
if (typeof
|
905 |
-
window[args['error']]
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
|
|
|
|
910 |
}
|
911 |
},
|
912 |
-
statusCode
|
913 |
|
914 |
});
|
915 |
}
|
916 |
|
917 |
|
918 |
-
|
919 |
/**
|
920 |
* Get information about the owner of the access_token.
|
921 |
*
|
@@ -923,7 +996,7 @@ function WDIInstagram(args) {
|
|
923 |
* @definition success_callback => which function to call in case of success
|
924 |
* @definition error_callback => which function to call in case of error
|
925 |
* @definition statusCode => StatusCode object.
|
926 |
-
*
|
927 |
* @param args = {
|
928 |
* success : 'success_callback',
|
929 |
* error : 'error_callback'
|
@@ -933,11 +1006,12 @@ function WDIInstagram(args) {
|
|
933 |
*
|
934 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
935 |
* or you can pass as callback function an anonymous function
|
936 |
-
*
|
937 |
*
|
938 |
* @return object of founded info
|
939 |
*/
|
940 |
-
this.getSelfInfo = function(args)
|
|
|
941 |
var instagram = this,
|
942 |
noArgument = false,
|
943 |
successFlag = false,
|
@@ -955,7 +1029,7 @@ function WDIInstagram(args) {
|
|
955 |
errorFlag = true;
|
956 |
}
|
957 |
|
958 |
-
if(
|
959 |
statusCode = args['statusCode'];
|
960 |
}
|
961 |
}
|
@@ -963,56 +1037,61 @@ function WDIInstagram(args) {
|
|
963 |
type: 'POST',
|
964 |
dataType: 'jsonp',
|
965 |
url: 'https://api.instagram.com/v1/users/self/?access_token=' + getAccessToken(),
|
966 |
-
success: function(response)
|
|
|
967 |
if (successFlag) {
|
968 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
969 |
if (typeof window[args.success[0]] != 'undefined') {
|
970 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
971 |
if (filter) {
|
972 |
-
response = filter(response,instagram.filterArguments);
|
973 |
}
|
974 |
window[args.success[0]][args.success[1]](response);
|
975 |
}
|
976 |
}
|
977 |
-
} else
|
978 |
-
if (typeof
|
979 |
-
if (
|
980 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
981 |
}
|
982 |
-
window[args.success](response);
|
983 |
-
}
|
984 |
-
} else if (typeof args.success == 'function') {
|
985 |
-
if (filter) {
|
986 |
-
response = filter(response,instagram.filterArguments);
|
987 |
-
}
|
988 |
-
args.success(response);
|
989 |
-
}
|
990 |
}
|
991 |
},
|
992 |
-
error: function(response)
|
|
|
993 |
if (errorFlag) {
|
994 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
995 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
996 |
window[args['error'][0]][args['error'][1]](response);
|
997 |
}
|
998 |
-
} else
|
999 |
-
if (typeof
|
1000 |
-
window[args['error']]
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
|
|
|
|
1005 |
}
|
1006 |
},
|
1007 |
-
statusCode
|
1008 |
|
1009 |
});
|
1010 |
}
|
1011 |
|
1012 |
|
1013 |
-
|
1014 |
/**
|
1015 |
-
* Get a list of recent comments on a media object.
|
1016 |
* The public_content permission scope is required to get comments for a media
|
1017 |
* that does not belong to the owner of the access_token.
|
1018 |
*
|
@@ -1020,7 +1099,7 @@ function WDIInstagram(args) {
|
|
1020 |
* @definition success_callback => which function to call in case of success
|
1021 |
* @definition error_callback => which function to call in case of error
|
1022 |
* @definition statusCode => StatusCode object.
|
1023 |
-
*
|
1024 |
* @param args = {
|
1025 |
* success : 'success_callback',
|
1026 |
* error : 'error_callback'
|
@@ -1030,11 +1109,12 @@ function WDIInstagram(args) {
|
|
1030 |
*
|
1031 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
1032 |
* or you can pass as callback function an anonymous function
|
1033 |
-
*
|
1034 |
*
|
1035 |
* @return object of founded comments
|
1036 |
*/
|
1037 |
-
this.getRecentMediaComments = function(media_id, args)
|
|
|
1038 |
var instagram = this,
|
1039 |
noArgument = false,
|
1040 |
successFlag = false,
|
@@ -1052,7 +1132,7 @@ function WDIInstagram(args) {
|
|
1052 |
errorFlag = true;
|
1053 |
}
|
1054 |
|
1055 |
-
if(
|
1056 |
statusCode = args['statusCode'];
|
1057 |
}
|
1058 |
}
|
@@ -1060,54 +1140,59 @@ function WDIInstagram(args) {
|
|
1060 |
type: 'POST',
|
1061 |
dataType: 'jsonp',
|
1062 |
url: 'https://api.instagram.com/v1/media/' + media_id + '/comments?access_token=' + getAccessToken(),
|
1063 |
-
success: function(response)
|
|
|
1064 |
if (successFlag) {
|
1065 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
1066 |
if (typeof window[args.success[0]] != 'undefined') {
|
1067 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
1068 |
if (filter) {
|
1069 |
-
response = filter(response,instagram.filterArguments);
|
1070 |
}
|
1071 |
window[args.success[0]][args.success[1]](response);
|
1072 |
}
|
1073 |
}
|
1074 |
-
} else
|
1075 |
-
if (typeof
|
1076 |
-
if (
|
1077 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1078 |
}
|
1079 |
-
window[args.success](response);
|
1080 |
-
}
|
1081 |
-
} else if (typeof args.success == 'function') {
|
1082 |
-
if (filter) {
|
1083 |
-
response = filter(response,instagram.filterArguments);
|
1084 |
-
}
|
1085 |
-
args.success(response);
|
1086 |
-
}
|
1087 |
}
|
1088 |
},
|
1089 |
-
error: function(response)
|
|
|
1090 |
if (errorFlag) {
|
1091 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
1092 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
1093 |
window[args['error'][0]][args['error'][1]](response);
|
1094 |
}
|
1095 |
-
} else
|
1096 |
-
if (typeof
|
1097 |
-
window[args['error']]
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
|
|
|
|
1102 |
}
|
1103 |
},
|
1104 |
-
statusCode
|
1105 |
|
1106 |
});
|
1107 |
}
|
1108 |
|
1109 |
|
1110 |
-
|
1111 |
/**
|
1112 |
* Get a list of users who have liked this media.
|
1113 |
*
|
@@ -1115,7 +1200,7 @@ function WDIInstagram(args) {
|
|
1115 |
* @definition success_callback => which function to call in case of success
|
1116 |
* @definition error_callback => which function to call in case of error
|
1117 |
* @definition statusCode => StatusCode object.
|
1118 |
-
*
|
1119 |
* @param args = {
|
1120 |
* success : 'success_callback',
|
1121 |
* error : 'error_callback'
|
@@ -1125,11 +1210,12 @@ function WDIInstagram(args) {
|
|
1125 |
*
|
1126 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
1127 |
* or you can pass as callback function an anonymous function
|
1128 |
-
*
|
1129 |
*
|
1130 |
* @return object of founded comments
|
1131 |
*/
|
1132 |
-
this.getRecentMediaLikes = function(media_id, args)
|
|
|
1133 |
var instagram = this,
|
1134 |
noArgument = false,
|
1135 |
successFlag = false,
|
@@ -1148,7 +1234,7 @@ function WDIInstagram(args) {
|
|
1148 |
errorFlag = true;
|
1149 |
}
|
1150 |
|
1151 |
-
if(
|
1152 |
statusCode = args['statusCode'];
|
1153 |
}
|
1154 |
}
|
@@ -1156,48 +1242,54 @@ function WDIInstagram(args) {
|
|
1156 |
type: 'POST',
|
1157 |
dataType: 'jsonp',
|
1158 |
url: 'https://api.instagram.com/v1/media/' + media_id + '/likes?access_token=' + getAccessToken(),
|
1159 |
-
success: function(response)
|
|
|
1160 |
if (successFlag) {
|
1161 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
1162 |
if (typeof window[args.success[0]] != 'undefined') {
|
1163 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
1164 |
if (filter) {
|
1165 |
-
response = filter(response,instagram.filterArguments);
|
1166 |
}
|
1167 |
window[args.success[0]][args.success[1]](response);
|
1168 |
}
|
1169 |
}
|
1170 |
-
} else
|
1171 |
-
if (typeof
|
1172 |
-
if (
|
1173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1174 |
}
|
1175 |
-
window[args.success](response);
|
1176 |
-
}
|
1177 |
-
} else if (typeof args.success == 'function') {
|
1178 |
-
if (filter) {
|
1179 |
-
response = filter(response,instagram.filterArguments);
|
1180 |
-
}
|
1181 |
-
args.success(response);
|
1182 |
-
}
|
1183 |
}
|
1184 |
},
|
1185 |
-
error: function(response)
|
|
|
1186 |
if (errorFlag) {
|
1187 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
1188 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
1189 |
window[args['error'][0]][args['error'][1]](response);
|
1190 |
}
|
1191 |
-
} else
|
1192 |
-
if (typeof
|
1193 |
-
window[args['error']]
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
|
|
|
|
1198 |
}
|
1199 |
},
|
1200 |
-
statusCode
|
1201 |
|
1202 |
});
|
1203 |
}
|
@@ -1210,7 +1302,7 @@ function WDIInstagram(args) {
|
|
1210 |
* @definition success_callback => which function to call in case of success
|
1211 |
* @definition error_callback => which function to call in case of error
|
1212 |
* @definition statusCode => StatusCode object.
|
1213 |
-
*
|
1214 |
* @param args = {
|
1215 |
* success : 'success_callback',
|
1216 |
* error : 'error_callback',
|
@@ -1221,11 +1313,12 @@ function WDIInstagram(args) {
|
|
1221 |
*
|
1222 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
1223 |
* or you can pass as callback function an anonymous function
|
1224 |
-
*
|
1225 |
*
|
1226 |
* @return object of founded media
|
1227 |
*/
|
1228 |
-
this.requestByUrl = function(requestUrl, args)
|
|
|
1229 |
var instagram = this,
|
1230 |
noArgument = false,
|
1231 |
successFlag = false,
|
@@ -1256,9 +1349,9 @@ function WDIInstagram(args) {
|
|
1256 |
successFlag = true;
|
1257 |
}
|
1258 |
|
1259 |
-
if (
|
1260 |
argFlag = true;
|
1261 |
-
}else{
|
1262 |
args.args = {};
|
1263 |
}
|
1264 |
|
@@ -1267,7 +1360,7 @@ function WDIInstagram(args) {
|
|
1267 |
errorFlag = true;
|
1268 |
}
|
1269 |
|
1270 |
-
if(
|
1271 |
statusCode = args['statusCode'];
|
1272 |
}
|
1273 |
}
|
@@ -1277,48 +1370,54 @@ function WDIInstagram(args) {
|
|
1277 |
type: 'POST',
|
1278 |
dataType: 'jsonp',
|
1279 |
url: requestUrl,
|
1280 |
-
success: function(response)
|
|
|
1281 |
if (successFlag) {
|
1282 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
1283 |
if (typeof window[args.success[0]] != 'undefined') {
|
1284 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
1285 |
if (filter) {
|
1286 |
-
response = filter(response,instagram.filterArguments, args.args);
|
1287 |
}
|
1288 |
window[args.success[0]][args.success[1]](response);
|
1289 |
}
|
1290 |
}
|
1291 |
-
} else
|
1292 |
-
if (typeof
|
1293 |
-
if (
|
1294 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1295 |
}
|
1296 |
-
window[args.success](response);
|
1297 |
-
}
|
1298 |
-
} else if (typeof args.success == 'function') {
|
1299 |
-
if (filter) {
|
1300 |
-
response = filter(response,instagram.filterArguments, args.args);
|
1301 |
-
}
|
1302 |
-
args.success(response);
|
1303 |
-
}
|
1304 |
}
|
1305 |
},
|
1306 |
-
error: function(response)
|
|
|
1307 |
if (errorFlag) {
|
1308 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
1309 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
1310 |
window[args['error'][0]][args['error'][1]](response);
|
1311 |
}
|
1312 |
-
} else
|
1313 |
-
if (typeof
|
1314 |
-
window[args['error']]
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
|
|
|
|
1319 |
}
|
1320 |
},
|
1321 |
-
statusCode
|
1322 |
|
1323 |
});
|
1324 |
|
@@ -1326,4 +1425,3 @@ function WDIInstagram(args) {
|
|
1326 |
}
|
1327 |
|
1328 |
|
1329 |
-
|
15 |
* searchForUsersByName = function( username, args ) : Get a list of users matching the query.
|
16 |
* searchForTagsByName = function(tagname, args) : Search for tags by name.
|
17 |
* getTagRecentMedia = function(tagname, args) : Gets recent media based on tagname
|
18 |
+
*
|
19 |
*/
|
20 |
|
21 |
|
22 |
|
23 |
/**
|
24 |
+
* example of arg
|
25 |
* @type {Object}
|
26 |
*/
|
27 |
// var args = {
|
38 |
// }
|
39 |
|
40 |
|
|
|
41 |
/**
|
42 |
* WDIInstagram object constructor
|
43 |
* @param {Object} args
|
46 |
* @param {Array} [args.filters] [array of object defining filters]
|
47 |
* @param {Object} [args.filters[i] ] [ filter object which contain 'where' : 'what' pair ]
|
48 |
* @param {String} [args.filters.filter[i].where] [name of function where filter must be applied]
|
49 |
+
* @param {String or Array} [args.filters.filter[i].what] [name of filtering function,
|
50 |
+
* if function is in global scope then it should be name of the funtion
|
51 |
+
* else if function in method of some object then it should be an array
|
52 |
* ['parent_object_name','filtering_function_name']]
|
53 |
*/
|
54 |
+
function WDIInstagram(args)
|
55 |
+
{
|
56 |
|
57 |
this.access_tokens = [];
|
58 |
this.filters = [];
|
73 |
* @type {Object}
|
74 |
*/
|
75 |
this.statusCode = {
|
76 |
+
429: function ()
|
77 |
+
{
|
78 |
+
console.log(' 429: Too many requests. Try after one hour');
|
79 |
},
|
80 |
}
|
81 |
|
82 |
/**
|
83 |
* gets filter function defined for specific method
|
84 |
* this function is internal function and cannot be called outside of this object
|
85 |
+
*
|
86 |
* @param {String} methodName [name of WDIInstagram method]
|
87 |
* @return {Function} [filtering function for {methodName}]
|
88 |
*/
|
89 |
+
this.getFilter = function (methodName)
|
90 |
+
{
|
91 |
var filters = _this.filters;
|
92 |
if (typeof filters == "undefined") {
|
93 |
return false;
|
102 |
return window[filters[i].what[0]][filters[i].what[1]];
|
103 |
}
|
104 |
}
|
105 |
+
} else
|
106 |
+
if (typeof filters[i].what == 'string') {
|
107 |
+
if (typeof window[filters[i].what] == 'function') {
|
108 |
+
return window[filters[i].what];
|
109 |
+
}
|
110 |
+
} else
|
111 |
+
if (typeof filters[i].what == 'function') {
|
112 |
+
return filters[i].what;
|
113 |
+
} else {
|
114 |
+
return false;
|
115 |
+
}
|
116 |
}
|
117 |
}
|
118 |
return false;
|
119 |
}
|
120 |
|
121 |
+
function getAccessToken()
|
122 |
+
{
|
123 |
var access_tokens = _this.access_tokens,
|
124 |
index = parseInt(Math.random(0, 1) * access_tokens.length);
|
125 |
return access_tokens[index];
|
130 |
* non string values are not allowed
|
131 |
* @param {String} token [Instagram API access token]
|
132 |
*/
|
133 |
+
this.addToken = function (token)
|
134 |
+
{
|
135 |
if (typeof token == 'string') {
|
136 |
_this.access_tokens.push(token);
|
137 |
}
|
162 |
*
|
163 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
164 |
* or you can pass as callback function an anonymous function
|
165 |
+
*
|
166 |
*
|
167 |
* @return object of founded media
|
168 |
*/
|
169 |
+
this.getTagRecentMedia = function (tagname, args)
|
170 |
+
{
|
171 |
var instagram = this,
|
172 |
noArgument = false,
|
173 |
successFlag = false,
|
175 |
errorFlag = false,
|
176 |
argFlag = false,
|
177 |
filter = this.getFilter('getTagRecentMedia'),
|
178 |
+
|
179 |
+
baseUrl = 'https://api.instagram.com/v1/tags/' + tagname + '/media/recent?access_token=' + getAccessToken();
|
180 |
|
181 |
|
182 |
if (typeof args == 'undefined' || args.length === 0) {
|
186 |
if ('success' in args) {
|
187 |
successFlag = true;
|
188 |
}
|
189 |
+
if ('statusCode' in args) {
|
190 |
statusCode = args['statusCode'];
|
191 |
}
|
192 |
if ('error' in args) {
|
193 |
errorFlag = true;
|
194 |
}
|
195 |
//
|
196 |
+
if ('args' in args) {
|
197 |
argFlag = true;
|
198 |
+
} else {
|
199 |
args.args = {};
|
200 |
}
|
201 |
//
|
223 |
type: 'POST',
|
224 |
url: baseUrl,
|
225 |
dataType: 'jsonp',
|
226 |
+
success: function (response)
|
227 |
+
{
|
228 |
+
if (typeof response["data"] === "undefined") response["data"] = [];
|
229 |
|
230 |
if (successFlag) {
|
231 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
232 |
if (typeof window[args.success[0]] != 'undefined') {
|
233 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
234 |
if (filter) {
|
235 |
+
response = filter(response, instagram.filterArguments, args.args);
|
236 |
}
|
237 |
window[args.success[0]][args.success[1]](response);
|
238 |
}
|
239 |
}
|
240 |
|
241 |
+
} else
|
242 |
+
if (typeof args.success == 'string') {
|
243 |
+
if (typeof window[args.success] == 'function') {
|
244 |
+
if (filter) {
|
245 |
+
response = filter(response, instagram.filterArguments, args.args);
|
246 |
+
}
|
247 |
+
window[args.success](response);
|
248 |
+
}
|
249 |
+
} else
|
250 |
+
if (typeof args.success == 'function') {
|
251 |
+
if (filter) {
|
252 |
+
response = filter(response, instagram.filterArguments, args.args);
|
253 |
+
}
|
254 |
+
args.success(response);
|
255 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
}
|
257 |
},
|
258 |
+
error: function (response)
|
259 |
+
{
|
260 |
if (errorFlag) {
|
261 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
262 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
263 |
window[args['error'][0]][args['error'][1]](response);
|
264 |
}
|
265 |
+
} else
|
266 |
+
if (typeof args['error'] == 'string') {
|
267 |
+
if (typeof window[args['error']] == 'function') {
|
268 |
+
window[args['error']](response);
|
269 |
+
}
|
270 |
+
} else
|
271 |
+
if (typeof args['error'] == 'function') {
|
272 |
+
args['error'](response);
|
273 |
+
}
|
274 |
}
|
275 |
},
|
276 |
+
statusCode: statusCode
|
277 |
});
|
278 |
|
279 |
}
|
297 |
*
|
298 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
299 |
* or you can pass as callback function an anonymous function
|
300 |
+
*
|
301 |
*
|
302 |
* @return object of founded media
|
303 |
*/
|
304 |
|
305 |
+
this.searchForTagsByName = function (tagname, args)
|
306 |
+
{
|
307 |
var instagram = this,
|
308 |
noArgument = false,
|
309 |
successFlag = false,
|
310 |
statusCode = this.statusCode;
|
311 |
+
errorFlag = false;
|
312 |
filter = this.getFilter('searchForTagsByName');
|
313 |
|
314 |
if (typeof args == 'undefined' || args.length === 0) {
|
320 |
if ('error' in args) {
|
321 |
errorFlag = true;
|
322 |
}
|
323 |
+
if ('statusCode' in args) {
|
324 |
statusCode = args['statusCode'];
|
325 |
}
|
326 |
}
|
330 |
type: 'POST',
|
331 |
url: 'https://api.instagram.com/v1/tags/search?q=' + tagname + '&access_token=' + getAccessToken(),
|
332 |
dataType: 'jsonp',
|
333 |
+
success: function (response)
|
334 |
+
{
|
335 |
if (successFlag) {
|
336 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
337 |
if (typeof window[args.success[0]] != 'undefined') {
|
338 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
339 |
if (filter) {
|
340 |
+
response = filter(response, instagram.filterArguments);
|
341 |
}
|
342 |
window[args.success[0]][args.success[1]](response);
|
343 |
}
|
344 |
}
|
345 |
+
} else
|
346 |
+
if (typeof args.success == 'string') {
|
347 |
+
if (typeof window[args.success] == 'function') {
|
348 |
+
if (filter) {
|
349 |
+
response = filter(response, instagram.filterArguments);
|
350 |
+
}
|
351 |
+
window[args.success](response);
|
352 |
+
}
|
353 |
+
} else
|
354 |
+
if (typeof args.success == 'function') {
|
355 |
+
if (filter) {
|
356 |
+
response = filter(response, instagram.filterArguments);
|
357 |
+
}
|
358 |
+
args.success(response);
|
359 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
360 |
}
|
361 |
},
|
362 |
+
error: function (response)
|
363 |
+
{
|
364 |
if (errorFlag) {
|
365 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
366 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
367 |
window[args['error'][0]][args['error'][1]](response);
|
368 |
}
|
369 |
+
} else
|
370 |
+
if (typeof args['error'] == 'string') {
|
371 |
+
if (typeof window[args['error']] == 'function') {
|
372 |
+
window[args['error']](response);
|
373 |
+
}
|
374 |
+
} else
|
375 |
+
if (typeof args['error'] == 'function') {
|
376 |
+
args['error'](response);
|
377 |
+
}
|
378 |
}
|
379 |
},
|
380 |
statusCode: statusCode
|
382 |
}
|
383 |
|
384 |
|
|
|
385 |
/**
|
386 |
* Get a list of users matching the query.
|
387 |
*
|
389 |
* @definition success_callback => which function to call in case of success
|
390 |
* @definition error_callback => which function to call in case of error
|
391 |
* @definition statusCode => StatusCode object.
|
392 |
+
*
|
393 |
* @param username
|
394 |
* @param args = {
|
395 |
* success: 'success_callback',
|
400 |
*
|
401 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
402 |
* or you can pass as callback function an anonymous function
|
403 |
+
*
|
404 |
*
|
405 |
* @return object of founded users
|
406 |
*/
|
407 |
+
this.searchForUsersByName = function (username, args)
|
408 |
+
{
|
409 |
var instagram = this,
|
410 |
noArgument = false,
|
411 |
successFlag = false,
|
422 |
if ('error' in args) {
|
423 |
errorFlag = true;
|
424 |
}
|
425 |
+
if ('statusCode' in args) {
|
426 |
statusCode = args['statusCode'];
|
427 |
}
|
428 |
}
|
432 |
type: 'POST',
|
433 |
dataType: 'jsonp',
|
434 |
url: 'https://api.instagram.com/v1/users/search?q=' + username + '&access_token=' + getAccessToken(),
|
435 |
+
success: function (response)
|
436 |
+
{
|
437 |
if (successFlag) {
|
438 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
439 |
if (typeof window[args.success[0]] != 'undefined') {
|
440 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
441 |
if (filter) {
|
442 |
+
response = filter(response, instagram.filterArguments);
|
443 |
}
|
444 |
response.args = args;
|
445 |
window[args.success[0]][args.success[1]](response);
|
446 |
}
|
447 |
}
|
448 |
+
} else
|
449 |
+
if (typeof args.success == 'string') {
|
450 |
+
if (typeof window[args.success] == 'function') {
|
451 |
+
if (filter) {
|
452 |
+
response = filter(response, instagram.filterArguments);
|
453 |
+
}
|
454 |
+
response.args = args;
|
455 |
+
window[args.success](response);
|
456 |
+
}
|
457 |
+
} else
|
458 |
+
if (typeof args.success == 'function') {
|
459 |
+
if (filter) {
|
460 |
+
response = filter(response, instagram.filterArguments);
|
461 |
+
}
|
462 |
+
response.args = args;
|
463 |
+
args.success(response);
|
464 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
465 |
}
|
466 |
},
|
467 |
+
error: function (response)
|
468 |
+
{
|
469 |
if (errorFlag) {
|
470 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
471 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
472 |
window[args['error'][0]][args['error'][1]](response);
|
473 |
}
|
474 |
+
} else
|
475 |
+
if (typeof args['error'] == 'string') {
|
476 |
+
if (typeof window[args['error']] == 'function') {
|
477 |
+
window[args['error']](response);
|
478 |
+
}
|
479 |
+
} else
|
480 |
+
if (typeof args['error'] == 'function') {
|
481 |
+
args['error'](response);
|
482 |
+
}
|
483 |
}
|
484 |
},
|
485 |
+
statusCode: this.statusCode
|
486 |
|
487 |
});
|
488 |
}
|
489 |
|
490 |
|
|
|
491 |
/**
|
492 |
* Get the list of recent media liked by the owner of the access_token.
|
493 |
*
|
494 |
*
|
495 |
* @definition success_callback => which function to call in case of success
|
496 |
* @definition error_callback => which function to call in case of error
|
497 |
+
* @definition statusCode => StatusCode object.
|
498 |
* @param args = {
|
499 |
* success: 'success_callback',
|
500 |
* error: 'error_callback',
|
504 |
*
|
505 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
506 |
* or you can pass as callback function an anonymous function
|
|
|
507 |
*
|
508 |
* @return object of founded media
|
509 |
*/
|
510 |
|
511 |
+
this.getRecentLikedMedia = function (args)
|
512 |
+
{
|
513 |
var instagram = this,
|
514 |
noArgument = false,
|
515 |
successFlag = false,
|
516 |
statusCode = this.statusCode,
|
517 |
errorFlag = false,
|
518 |
+
filter = this.getFilter('getRecentLikedMedia'),
|
519 |
+
baseUrl = 'https://api.instagram.com/v1/users/self/media/liked?access_token=' + getAccessToken();
|
520 |
|
521 |
if (typeof args == 'undefined' || args.length === 0) {
|
522 |
noArgument = true;
|
527 |
if ('error' in args) {
|
528 |
errorFlag = true;
|
529 |
}
|
530 |
+
if ('statusCode' in args) {
|
531 |
statusCode = args['statusCode'];
|
532 |
}
|
533 |
+
if ('args' in args) {
|
534 |
+
argFlag = true;
|
535 |
+
} else {
|
536 |
+
args.args = {};
|
537 |
+
}
|
538 |
+
|
539 |
+
if ('count' in args) {
|
540 |
+
args['count'] = parseInt(args['count']);
|
541 |
+
if (!Number.isInteger(args['count']) || args['count'] <= 0) {
|
542 |
+
args.count = 20;
|
543 |
+
}
|
544 |
+
} else {
|
545 |
+
args.count = 20;
|
546 |
+
}
|
547 |
+
|
548 |
+
baseUrl += '&count=' + args.count;
|
549 |
+
|
550 |
+
if ('next_max_like_id' in args) {
|
551 |
+
baseUrl += '&next_max_like_id=' + args.next_max_like_id;
|
552 |
+
}
|
553 |
+
|
554 |
+
|
555 |
}
|
556 |
|
557 |
|
558 |
jQuery.ajax({
|
559 |
type: 'POST',
|
560 |
dataType: 'jsonp',
|
561 |
+
url: baseUrl,
|
562 |
+
success: function (response)
|
563 |
+
{
|
564 |
if (successFlag) {
|
565 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
566 |
if (typeof window[args.success[0]] != 'undefined') {
|
567 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
568 |
if (filter) {
|
569 |
+
response = filter(response, instagram.filterArguments, args.args);
|
570 |
}
|
571 |
window[args.success[0]][args.success[1]](response);
|
572 |
}
|
573 |
}
|
574 |
+
} else
|
575 |
+
if (typeof args.success == 'string') {
|
576 |
+
if (typeof window[args.success] == 'function') {
|
577 |
+
if (filter) {
|
578 |
+
response = filter(response, instagram.filterArguments, args.args);
|
579 |
+
}
|
580 |
+
window[args.success](response);
|
581 |
+
}
|
582 |
+
} else
|
583 |
+
if (typeof args.success == 'function') {
|
584 |
+
if (filter) {
|
585 |
+
response = filter(response, instagram.filterArguments, args.args);
|
586 |
+
}
|
587 |
+
args.success(response);
|
588 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
589 |
}
|
590 |
},
|
591 |
+
error: function (response)
|
592 |
+
{
|
593 |
if (errorFlag) {
|
594 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
595 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
596 |
window[args['error'][0]][args['error'][1]](response);
|
597 |
}
|
598 |
+
} else
|
599 |
+
if (typeof args['error'] == 'string') {
|
600 |
+
if (typeof window[args['error']] == 'function') {
|
601 |
+
window[args['error']](response);
|
602 |
+
}
|
603 |
+
} else
|
604 |
+
if (typeof args['error'] == 'function') {
|
605 |
+
args['error'](response);
|
606 |
+
}
|
607 |
}
|
608 |
},
|
609 |
+
statusCode: statusCode
|
610 |
|
611 |
});
|
612 |
}
|
613 |
|
614 |
|
|
|
615 |
/**
|
616 |
+
* Get the most recent media published by a user.
|
617 |
* This endpoint requires the public_content scope if the user-id is not the owner of the access_token.
|
618 |
*
|
619 |
*
|
623 |
* @definition min_id => Return media before this min_id.
|
624 |
* @definition max_id => Return media after this max_id.
|
625 |
* @definition statusCode => StatusCode object.
|
626 |
+
*
|
627 |
* @param args = {
|
628 |
* success : 'success_callback',
|
629 |
* error : 'error_callback',
|
637 |
*
|
638 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
639 |
* or you can pass as callback function an anonymous function
|
640 |
+
*
|
641 |
*
|
642 |
* @return object of founded media
|
643 |
*/
|
644 |
+
this.getUserRecentMedia = function (user_id, args)
|
645 |
+
{
|
646 |
var instagram = this,
|
647 |
noArgument = false,
|
648 |
successFlag = false,
|
649 |
argFlag = false,
|
650 |
+
//internal default object for statusCode handling
|
651 |
statusCode = this.statusCode,
|
652 |
errorFlag = false,
|
653 |
filter = this.getFilter('getUserRecentMedia'),
|
654 |
baseUrl = 'https://api.instagram.com/v1/users/' + user_id + '/media/recent/?access_token=' + getAccessToken();
|
655 |
+
|
656 |
+
|
657 |
if (typeof args == 'undefined' || args.length === 0) {
|
658 |
noArgument = true;
|
659 |
} else {
|
661 |
successFlag = true;
|
662 |
}
|
663 |
|
664 |
+
if ('statusCode' in args) {
|
665 |
statusCode = args['statusCode'];
|
666 |
}
|
667 |
+
|
668 |
+
if ('args' in args) {
|
669 |
argFlag = true;
|
670 |
+
} else {
|
671 |
args.args = {};
|
672 |
}
|
673 |
|
700 |
type: 'POST',
|
701 |
dataType: 'jsonp',
|
702 |
url: baseUrl,
|
703 |
+
success: function (response)
|
704 |
+
{
|
705 |
+
if (typeof response["data"] === "undefined") response["data"] = [];
|
706 |
|
707 |
if (successFlag) {
|
708 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
709 |
if (typeof window[args.success[0]] != 'undefined') {
|
710 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
711 |
if (filter) {
|
712 |
+
response = filter(response, instagram.filterArguments, args.args);
|
713 |
}
|
714 |
window[args.success[0]][args.success[1]](response);
|
715 |
}
|
716 |
}
|
717 |
+
} else
|
718 |
+
if (typeof args.success == 'string') {
|
719 |
+
if (typeof window[args.success] == 'function') {
|
720 |
+
if (filter) {
|
721 |
+
response = filter(response, instagram.filterArguments, args.args);
|
722 |
+
}
|
723 |
+
window[args.success](response);
|
724 |
+
}
|
725 |
+
} else
|
726 |
+
if (typeof args.success == 'function') {
|
727 |
+
if (filter) {
|
728 |
+
response = filter(response, instagram.filterArguments, args.args);
|
729 |
+
}
|
730 |
+
args.success(response);
|
731 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
732 |
}
|
733 |
},
|
734 |
+
error: function (response)
|
735 |
+
{
|
736 |
if (errorFlag) {
|
737 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
738 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
739 |
window[args['error'][0]][args['error'][1]](response);
|
740 |
}
|
741 |
+
} else
|
742 |
+
if (typeof args['error'] == 'string') {
|
743 |
+
if (typeof window[args['error']] == 'function') {
|
744 |
+
window[args['error']](response);
|
745 |
+
}
|
746 |
+
} else
|
747 |
+
if (typeof args['error'] == 'function') {
|
748 |
+
args['error'](response);
|
749 |
+
}
|
750 |
}
|
751 |
},
|
752 |
statusCode: statusCode
|
756 |
}
|
757 |
|
758 |
|
|
|
759 |
/**
|
760 |
* Get the most recent media published by the owner of the access_token.
|
761 |
*
|
766 |
* @definition min_id => Return media before this min_id.
|
767 |
* @definition max_id => Return media after this max_id.
|
768 |
* @definition statusCode => StatusCode object.
|
769 |
+
*
|
770 |
* @param args = {
|
771 |
* success : 'success_callback',
|
772 |
* error : 'error_callback',
|
774 |
* min_id : 'min_id'
|
775 |
* max_id : 'max_id'
|
776 |
* statusCode : statusCode
|
777 |
+
*
|
778 |
* }
|
779 |
*
|
780 |
*
|
781 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
782 |
* or you can pass as callback function an anonymous function
|
783 |
+
*
|
784 |
*
|
785 |
* @return object of founded media
|
786 |
*/
|
787 |
+
this.getSelfRecentMedia = function (args)
|
788 |
+
{
|
789 |
var instagram = this,
|
790 |
noArgument = false,
|
791 |
successFlag = false,
|
792 |
statusCode = this.statusCode;
|
793 |
+
errorFlag = false,
|
794 |
filter = this.getFilter('getSelfRecentMedia'),
|
795 |
baseUrl = 'https://api.instagram.com/v1/users/self/media/recent/?access_token=' + getAccessToken();
|
796 |
|
805 |
errorFlag = true;
|
806 |
}
|
807 |
|
808 |
+
if ('statusCode' in args) {
|
809 |
statusCode = args['statusCode'];
|
810 |
}
|
811 |
|
833 |
type: 'POST',
|
834 |
dataType: 'jsonp',
|
835 |
url: baseUrl,
|
836 |
+
success: function (response)
|
837 |
+
{
|
838 |
if (successFlag) {
|
839 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
840 |
if (typeof window[args.success[0]] != 'undefined') {
|
841 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
842 |
if (filter) {
|
843 |
+
response = filter(response, instagram.filterArguments);
|
844 |
}
|
845 |
window[args.success[0]][args.success[1]](response);
|
846 |
}
|
847 |
}
|
848 |
+
} else
|
849 |
+
if (typeof args.success == 'string') {
|
850 |
+
if (typeof window[args.success] == 'function') {
|
851 |
+
if (filter) {
|
852 |
+
response = filter(response, instagram.filterArguments);
|
853 |
+
}
|
854 |
+
window[args.success](response);
|
855 |
+
}
|
856 |
+
} else
|
857 |
+
if (typeof args.success == 'function') {
|
858 |
+
if (filter) {
|
859 |
+
response = filter(response, instagram.filterArguments);
|
860 |
+
}
|
861 |
+
args.success(response);
|
862 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
863 |
}
|
864 |
},
|
865 |
+
error: function (response)
|
866 |
+
{
|
867 |
if (errorFlag) {
|
868 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
869 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
870 |
window[args['error'][0]][args['error'][1]](response);
|
871 |
}
|
872 |
+
} else
|
873 |
+
if (typeof args['error'] == 'string') {
|
874 |
+
if (typeof window[args['error']] == 'function') {
|
875 |
+
window[args['error']](response);
|
876 |
+
}
|
877 |
+
} else
|
878 |
+
if (typeof args['error'] == 'function') {
|
879 |
+
args['error'](response);
|
880 |
+
}
|
881 |
}
|
882 |
},
|
883 |
+
statusCode: statusCode
|
884 |
|
885 |
});
|
886 |
}
|
887 |
|
888 |
|
|
|
889 |
/**
|
890 |
+
* Get information about a user.
|
891 |
* This endpoint requires the public_content scope if the user-id is not the owner of the access_token.
|
892 |
*
|
893 |
*
|
894 |
* @definition success_callback => which function to call in case of success
|
895 |
* @definition error_callback => which function to call in case of error
|
896 |
* @definition statusCode => StatusCode object.
|
897 |
+
*
|
898 |
* @param args = {
|
899 |
* success : 'success_callback',
|
900 |
* error : 'error_callback'
|
904 |
*
|
905 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
906 |
* or you can pass as callback function an anonymous function
|
907 |
+
*
|
908 |
*
|
909 |
* @return object of founded info
|
910 |
*/
|
911 |
+
this.getUserInfo = function (user_id, args)
|
912 |
+
{
|
913 |
var instagram = this,
|
914 |
noArgument = false,
|
915 |
successFlag = false,
|
928 |
errorFlag = true;
|
929 |
}
|
930 |
|
931 |
+
if ('statusCode' in args) {
|
932 |
statusCode = args['statusCode'];
|
933 |
}
|
934 |
}
|
936 |
type: 'POST',
|
937 |
dataType: 'jsonp',
|
938 |
url: 'https://api.instagram.com/v1/users/' + user_id + '/?access_token=' + getAccessToken(),
|
939 |
+
success: function (response)
|
940 |
+
{
|
941 |
if (successFlag) {
|
942 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
943 |
if (typeof window[args.success[0]] != 'undefined') {
|
944 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
945 |
if (filter) {
|
946 |
+
response = filter(response, instagram.filterArguments);
|
947 |
}
|
948 |
window[args.success[0]][args.success[1]](response);
|
949 |
}
|
950 |
}
|
951 |
+
} else
|
952 |
+
if (typeof args.success == 'string') {
|
953 |
+
if (typeof window[args.success] == 'function') {
|
954 |
+
if (filter) {
|
955 |
+
response = filter(response, instagram.filterArguments);
|
956 |
+
}
|
957 |
+
window[args.success](response);
|
958 |
+
}
|
959 |
+
} else
|
960 |
+
if (typeof args.success == 'function') {
|
961 |
+
if (filter) {
|
962 |
+
response = filter(response, instagram.filterArguments);
|
963 |
+
}
|
964 |
+
args.success(response);
|
965 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
966 |
}
|
967 |
},
|
968 |
+
error: function (response)
|
969 |
+
{
|
970 |
if (errorFlag) {
|
971 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
972 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
973 |
window[args['error'][0]][args['error'][1]](response);
|
974 |
}
|
975 |
+
} else
|
976 |
+
if (typeof args['error'] == 'string') {
|
977 |
+
if (typeof window[args['error']] == 'function') {
|
978 |
+
window[args['error']](response);
|
979 |
+
}
|
980 |
+
} else
|
981 |
+
if (typeof args['error'] == 'function') {
|
982 |
+
args['error'](response);
|
983 |
+
}
|
984 |
}
|
985 |
},
|
986 |
+
statusCode: statusCode
|
987 |
|
988 |
});
|
989 |
}
|
990 |
|
991 |
|
|
|
992 |
/**
|
993 |
* Get information about the owner of the access_token.
|
994 |
*
|
996 |
* @definition success_callback => which function to call in case of success
|
997 |
* @definition error_callback => which function to call in case of error
|
998 |
* @definition statusCode => StatusCode object.
|
999 |
+
*
|
1000 |
* @param args = {
|
1001 |
* success : 'success_callback',
|
1002 |
* error : 'error_callback'
|
1006 |
*
|
1007 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
1008 |
* or you can pass as callback function an anonymous function
|
1009 |
+
*
|
1010 |
*
|
1011 |
* @return object of founded info
|
1012 |
*/
|
1013 |
+
this.getSelfInfo = function (args)
|
1014 |
+
{
|
1015 |
var instagram = this,
|
1016 |
noArgument = false,
|
1017 |
successFlag = false,
|
1029 |
errorFlag = true;
|
1030 |
}
|
1031 |
|
1032 |
+
if ('statusCode' in args) {
|
1033 |
statusCode = args['statusCode'];
|
1034 |
}
|
1035 |
}
|
1037 |
type: 'POST',
|
1038 |
dataType: 'jsonp',
|
1039 |
url: 'https://api.instagram.com/v1/users/self/?access_token=' + getAccessToken(),
|
1040 |
+
success: function (response)
|
1041 |
+
{
|
1042 |
if (successFlag) {
|
1043 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
1044 |
if (typeof window[args.success[0]] != 'undefined') {
|
1045 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
1046 |
if (filter) {
|
1047 |
+
response = filter(response, instagram.filterArguments);
|
1048 |
}
|
1049 |
window[args.success[0]][args.success[1]](response);
|
1050 |
}
|
1051 |
}
|
1052 |
+
} else
|
1053 |
+
if (typeof args.success == 'string') {
|
1054 |
+
if (typeof window[args.success] == 'function') {
|
1055 |
+
if (filter) {
|
1056 |
+
response = filter(response, instagram.filterArguments);
|
1057 |
+
}
|
1058 |
+
window[args.success](response);
|
1059 |
+
}
|
1060 |
+
} else
|
1061 |
+
if (typeof args.success == 'function') {
|
1062 |
+
if (filter) {
|
1063 |
+
response = filter(response, instagram.filterArguments);
|
1064 |
+
}
|
1065 |
+
args.success(response);
|
1066 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1067 |
}
|
1068 |
},
|
1069 |
+
error: function (response)
|
1070 |
+
{
|
1071 |
if (errorFlag) {
|
1072 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
1073 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
1074 |
window[args['error'][0]][args['error'][1]](response);
|
1075 |
}
|
1076 |
+
} else
|
1077 |
+
if (typeof args['error'] == 'string') {
|
1078 |
+
if (typeof window[args['error']] == 'function') {
|
1079 |
+
window[args['error']](response);
|
1080 |
+
}
|
1081 |
+
} else
|
1082 |
+
if (typeof args['error'] == 'function') {
|
1083 |
+
args['error'](response);
|
1084 |
+
}
|
1085 |
}
|
1086 |
},
|
1087 |
+
statusCode: statusCode
|
1088 |
|
1089 |
});
|
1090 |
}
|
1091 |
|
1092 |
|
|
|
1093 |
/**
|
1094 |
+
* Get a list of recent comments on a media object.
|
1095 |
* The public_content permission scope is required to get comments for a media
|
1096 |
* that does not belong to the owner of the access_token.
|
1097 |
*
|
1099 |
* @definition success_callback => which function to call in case of success
|
1100 |
* @definition error_callback => which function to call in case of error
|
1101 |
* @definition statusCode => StatusCode object.
|
1102 |
+
*
|
1103 |
* @param args = {
|
1104 |
* success : 'success_callback',
|
1105 |
* error : 'error_callback'
|
1109 |
*
|
1110 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
1111 |
* or you can pass as callback function an anonymous function
|
1112 |
+
*
|
1113 |
*
|
1114 |
* @return object of founded comments
|
1115 |
*/
|
1116 |
+
this.getRecentMediaComments = function (media_id, args)
|
1117 |
+
{
|
1118 |
var instagram = this,
|
1119 |
noArgument = false,
|
1120 |
successFlag = false,
|
1132 |
errorFlag = true;
|
1133 |
}
|
1134 |
|
1135 |
+
if ('statusCode' in args) {
|
1136 |
statusCode = args['statusCode'];
|
1137 |
}
|
1138 |
}
|
1140 |
type: 'POST',
|
1141 |
dataType: 'jsonp',
|
1142 |
url: 'https://api.instagram.com/v1/media/' + media_id + '/comments?access_token=' + getAccessToken(),
|
1143 |
+
success: function (response)
|
1144 |
+
{
|
1145 |
if (successFlag) {
|
1146 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
1147 |
if (typeof window[args.success[0]] != 'undefined') {
|
1148 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
1149 |
if (filter) {
|
1150 |
+
response = filter(response, instagram.filterArguments);
|
1151 |
}
|
1152 |
window[args.success[0]][args.success[1]](response);
|
1153 |
}
|
1154 |
}
|
1155 |
+
} else
|
1156 |
+
if (typeof args.success == 'string') {
|
1157 |
+
if (typeof window[args.success] == 'function') {
|
1158 |
+
if (filter) {
|
1159 |
+
response = filter(response, instagram.filterArguments);
|
1160 |
+
}
|
1161 |
+
window[args.success](response);
|
1162 |
+
}
|
1163 |
+
} else
|
1164 |
+
if (typeof args.success == 'function') {
|
1165 |
+
if (filter) {
|
1166 |
+
response = filter(response, instagram.filterArguments);
|
1167 |
+
}
|
1168 |
+
args.success(response);
|
1169 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1170 |
}
|
1171 |
},
|
1172 |
+
error: function (response)
|
1173 |
+
{
|
1174 |
if (errorFlag) {
|
1175 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
1176 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
1177 |
window[args['error'][0]][args['error'][1]](response);
|
1178 |
}
|
1179 |
+
} else
|
1180 |
+
if (typeof args['error'] == 'string') {
|
1181 |
+
if (typeof window[args['error']] == 'function') {
|
1182 |
+
window[args['error']](response);
|
1183 |
+
}
|
1184 |
+
} else
|
1185 |
+
if (typeof args['error'] == 'function') {
|
1186 |
+
args['error'](response);
|
1187 |
+
}
|
1188 |
}
|
1189 |
},
|
1190 |
+
statusCode: statusCode
|
1191 |
|
1192 |
});
|
1193 |
}
|
1194 |
|
1195 |
|
|
|
1196 |
/**
|
1197 |
* Get a list of users who have liked this media.
|
1198 |
*
|
1200 |
* @definition success_callback => which function to call in case of success
|
1201 |
* @definition error_callback => which function to call in case of error
|
1202 |
* @definition statusCode => StatusCode object.
|
1203 |
+
*
|
1204 |
* @param args = {
|
1205 |
* success : 'success_callback',
|
1206 |
* error : 'error_callback'
|
1210 |
*
|
1211 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
1212 |
* or you can pass as callback function an anonymous function
|
1213 |
+
*
|
1214 |
*
|
1215 |
* @return object of founded comments
|
1216 |
*/
|
1217 |
+
this.getRecentMediaLikes = function (media_id, args)
|
1218 |
+
{
|
1219 |
var instagram = this,
|
1220 |
noArgument = false,
|
1221 |
successFlag = false,
|
1234 |
errorFlag = true;
|
1235 |
}
|
1236 |
|
1237 |
+
if ('statusCode' in args) {
|
1238 |
statusCode = args['statusCode'];
|
1239 |
}
|
1240 |
}
|
1242 |
type: 'POST',
|
1243 |
dataType: 'jsonp',
|
1244 |
url: 'https://api.instagram.com/v1/media/' + media_id + '/likes?access_token=' + getAccessToken(),
|
1245 |
+
success: function (response)
|
1246 |
+
{
|
1247 |
if (successFlag) {
|
1248 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
1249 |
if (typeof window[args.success[0]] != 'undefined') {
|
1250 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
1251 |
if (filter) {
|
1252 |
+
response = filter(response, instagram.filterArguments);
|
1253 |
}
|
1254 |
window[args.success[0]][args.success[1]](response);
|
1255 |
}
|
1256 |
}
|
1257 |
+
} else
|
1258 |
+
if (typeof args.success == 'string') {
|
1259 |
+
if (typeof window[args.success] == 'function') {
|
1260 |
+
if (filter) {
|
1261 |
+
response = filter(response, instagram.filterArguments);
|
1262 |
+
}
|
1263 |
+
window[args.success](response);
|
1264 |
+
}
|
1265 |
+
} else
|
1266 |
+
if (typeof args.success == 'function') {
|
1267 |
+
if (filter) {
|
1268 |
+
response = filter(response, instagram.filterArguments);
|
1269 |
+
}
|
1270 |
+
args.success(response);
|
1271 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1272 |
}
|
1273 |
},
|
1274 |
+
error: function (response)
|
1275 |
+
{
|
1276 |
if (errorFlag) {
|
1277 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
1278 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
1279 |
window[args['error'][0]][args['error'][1]](response);
|
1280 |
}
|
1281 |
+
} else
|
1282 |
+
if (typeof args['error'] == 'string') {
|
1283 |
+
if (typeof window[args['error']] == 'function') {
|
1284 |
+
window[args['error']](response);
|
1285 |
+
}
|
1286 |
+
} else
|
1287 |
+
if (typeof args['error'] == 'function') {
|
1288 |
+
args['error'](response);
|
1289 |
+
}
|
1290 |
}
|
1291 |
},
|
1292 |
+
statusCode: statusCode
|
1293 |
|
1294 |
});
|
1295 |
}
|
1302 |
* @definition success_callback => which function to call in case of success
|
1303 |
* @definition error_callback => which function to call in case of error
|
1304 |
* @definition statusCode => StatusCode object.
|
1305 |
+
*
|
1306 |
* @param args = {
|
1307 |
* success : 'success_callback',
|
1308 |
* error : 'error_callback',
|
1313 |
*
|
1314 |
* if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
|
1315 |
* or you can pass as callback function an anonymous function
|
1316 |
+
*
|
1317 |
*
|
1318 |
* @return object of founded media
|
1319 |
*/
|
1320 |
+
this.requestByUrl = function (requestUrl, args)
|
1321 |
+
{
|
1322 |
var instagram = this,
|
1323 |
noArgument = false,
|
1324 |
successFlag = false,
|
1349 |
successFlag = true;
|
1350 |
}
|
1351 |
|
1352 |
+
if ('args' in args) {
|
1353 |
argFlag = true;
|
1354 |
+
} else {
|
1355 |
args.args = {};
|
1356 |
}
|
1357 |
|
1360 |
errorFlag = true;
|
1361 |
}
|
1362 |
|
1363 |
+
if ('statusCode' in args) {
|
1364 |
statusCode = args['statusCode'];
|
1365 |
}
|
1366 |
}
|
1370 |
type: 'POST',
|
1371 |
dataType: 'jsonp',
|
1372 |
url: requestUrl,
|
1373 |
+
success: function (response)
|
1374 |
+
{
|
1375 |
if (successFlag) {
|
1376 |
if (typeof args.success == 'object' && args.success.length == 2) {
|
1377 |
if (typeof window[args.success[0]] != 'undefined') {
|
1378 |
if (typeof window[args.success[0]][args.success[1]] == 'function') {
|
1379 |
if (filter) {
|
1380 |
+
response = filter(response, instagram.filterArguments, args.args);
|
1381 |
}
|
1382 |
window[args.success[0]][args.success[1]](response);
|
1383 |
}
|
1384 |
}
|
1385 |
+
} else
|
1386 |
+
if (typeof args.success == 'string') {
|
1387 |
+
if (typeof window[args.success] == 'function') {
|
1388 |
+
if (filter) {
|
1389 |
+
response = filter(response, instagram.filterArguments, args.args);
|
1390 |
+
}
|
1391 |
+
window[args.success](response);
|
1392 |
+
}
|
1393 |
+
} else
|
1394 |
+
if (typeof args.success == 'function') {
|
1395 |
+
if (filter) {
|
1396 |
+
response = filter(response, instagram.filterArguments, args.args);
|
1397 |
+
}
|
1398 |
+
args.success(response);
|
1399 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1400 |
}
|
1401 |
},
|
1402 |
+
error: function (response)
|
1403 |
+
{
|
1404 |
if (errorFlag) {
|
1405 |
if (typeof args['error'] == 'object' && args['error'].length == 2) {
|
1406 |
if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
|
1407 |
window[args['error'][0]][args['error'][1]](response);
|
1408 |
}
|
1409 |
+
} else
|
1410 |
+
if (typeof args['error'] == 'string') {
|
1411 |
+
if (typeof window[args['error']] == 'function') {
|
1412 |
+
window[args['error']](response);
|
1413 |
+
}
|
1414 |
+
} else
|
1415 |
+
if (typeof args['error'] == 'function') {
|
1416 |
+
args['error'](response);
|
1417 |
+
}
|
1418 |
}
|
1419 |
},
|
1420 |
+
statusCode: statusCode
|
1421 |
|
1422 |
});
|
1423 |
|
1425 |
}
|
1426 |
|
1427 |
|
|
js/wdi_responsive.js
CHANGED
@@ -1,291 +1,285 @@
|
|
1 |
/////////////////////Responsive////////////////////
|
2 |
-
jQuery(document).ready(function()
|
|
|
3 |
|
4 |
});
|
5 |
-
function wdi_responsive()
|
|
|
|
|
6 |
|
7 |
/*
|
8 |
* Calculates current column layout and gives proper column classes
|
9 |
*/
|
10 |
-
wdi_responsive.columnControl = function(currentFeed,load,customWidth)
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
});
|
165 |
-
|
166 |
-
}
|
167 |
-
}
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
});
|
175 |
-
|
176 |
-
}
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
};
|
182 |
-
wdi_responsive.bindCaptionEvent = function(imgtitle,currentFeed)
|
183 |
-
|
|
|
184 |
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
}
|
189 |
-
wdi_responsive.bindMasonryCaptionEvent = function(imgtitle,currentFeed)
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
|
|
194 |
}
|
195 |
-
wdi_responsive.showCaption = function(caption,currentFeedCounter)
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
|
|
251 |
|
252 |
}
|
253 |
-
wdi_responsive.fixRow = function(currentFeed)
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
|
|
|
|
|
|
|
|
275 |
}
|
276 |
|
277 |
-
wdi_responsive.showMasonryCaption = function(caption,currentFeedCounter)
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
|
|
291 |
}
|
1 |
/////////////////////Responsive////////////////////
|
2 |
+
jQuery(document).ready(function ()
|
3 |
+
{
|
4 |
|
5 |
});
|
6 |
+
function wdi_responsive()
|
7 |
+
{
|
8 |
+
};
|
9 |
|
10 |
/*
|
11 |
* Calculates current column layout and gives proper column classes
|
12 |
*/
|
13 |
+
wdi_responsive.columnControl = function (currentFeed, load, customWidth)
|
14 |
+
{
|
15 |
+
currentFeed.openRows = [];
|
16 |
+
if (load === 1) {
|
17 |
+
var wrapper = jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + " .wdi_feed_wrapper");
|
18 |
+
var itemWidth = jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + " .wdi_feed_item").css('width') + '';
|
19 |
+
var containerWidth = wrapper.width();
|
20 |
+
|
21 |
+
if (itemWidth.substr(itemWidth.length - 2, itemWidth.length) == 'px') {
|
22 |
+
itemWidth = parseFloat(itemWidth);
|
23 |
+
} else {
|
24 |
+
itemWidth = 0.01 * containerWidth * parseFloat(itemWidth);
|
25 |
+
}
|
26 |
+
|
27 |
+
if (currentFeed.feed_row.feed_type == 'masonry') {
|
28 |
+
var itemWidth = jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + " .wdi_masonry_column").width();
|
29 |
+
}
|
30 |
+
|
31 |
+
if (customWidth != undefined) {
|
32 |
+
itemWidth = customWidth;
|
33 |
+
}
|
34 |
+
var currentClass = wrapper.attr('wdi-res');
|
35 |
+
var newClass = currentClass.substr(0, 8) + Math.round(containerWidth / itemWidth);
|
36 |
+
wrapper.removeClass(currentClass);
|
37 |
+
wrapper.attr('wdi-res', newClass);
|
38 |
+
wrapper.addClass(newClass);
|
39 |
+
|
40 |
+
|
41 |
+
//////////////////////////////////////////
|
42 |
+
if (currentClass != newClass) {
|
43 |
+
var colNum = newClass.substr(8, newClass.length);
|
44 |
+
//updating free spaces for pagination view
|
45 |
+
if (currentFeed.feed_row.feed_display_view == 'pagination') {
|
46 |
+
currentFeed.freeSpaces = (Math.floor(currentFeed.feed_row.pagination_per_page_number / Math.round(containerWidth / itemWidth)) + 1) * Math.round(containerWidth / itemWidth) - currentFeed.feed_row.pagination_per_page_number;
|
47 |
+
if (currentFeed.freeSpaces % colNum == 0) {
|
48 |
+
currentFeed.freeSpaces = 0;
|
49 |
+
}
|
50 |
+
//updating pagination indexes for new layout
|
51 |
+
currentFeed.resIndex = 0;
|
52 |
+
var k = 0;
|
53 |
+
jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + ' .wdi_feed_item').each(function ()
|
54 |
+
{
|
55 |
+
jQuery(this).attr('wdi_res_index', currentFeed.resIndex);
|
56 |
+
if ((k + 1) % currentFeed.feed_row.pagination_per_page_number === 0) {
|
57 |
+
currentFeed.resIndex += currentFeed.freeSpaces + 1;
|
58 |
+
} else {
|
59 |
+
currentFeed.resIndex++;
|
60 |
+
}
|
61 |
+
k++;
|
62 |
+
});
|
63 |
+
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
} else {
|
69 |
+
jQuery(window).resize(function ()
|
70 |
+
{
|
71 |
+
|
72 |
+
|
73 |
+
var wrapper = jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + " .wdi_feed_wrapper");
|
74 |
+
if (wrapper.length == 0) {
|
75 |
+
return;
|
76 |
+
}
|
77 |
+
var itemWidth = jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + " .wdi_feed_item").css('width') + '';
|
78 |
+
var containerWidth = wrapper.width();
|
79 |
+
|
80 |
+
if (itemWidth.substr(itemWidth.length - 2, itemWidth.length) == 'px') {
|
81 |
+
itemWidth = parseFloat(itemWidth);
|
82 |
+
} else {
|
83 |
+
itemWidth = 0.01 * containerWidth * parseFloat(itemWidth);
|
84 |
+
}
|
85 |
+
|
86 |
+
var currentClass = wrapper.attr('wdi-res');
|
87 |
+
|
88 |
+
|
89 |
+
//check if layout was changed then reposition masonry
|
90 |
+
if (currentFeed.feed_row.feed_type == 'masonry') {
|
91 |
+
var itemWidth = jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + " .wdi_masonry_column").width();
|
92 |
+
}
|
93 |
+
var newClass = currentClass.substr(0, 8) + Math.round(containerWidth / itemWidth);
|
94 |
+
wrapper.removeClass(currentClass);
|
95 |
+
wrapper.attr('wdi-res', newClass);
|
96 |
+
wrapper.addClass(newClass);
|
97 |
+
|
98 |
+
|
99 |
+
//Feed type based configurations
|
100 |
+
if (currentFeed.feed_row.feed_type === 'thumbnails') {
|
101 |
+
//fixes row which was opened by user
|
102 |
+
wdi_responsive.fixRow(currentFeed);
|
103 |
+
}
|
104 |
+
if (currentFeed.feed_row.feed_type === 'masonry') {
|
105 |
+
//checking if layout changed then change masonry columns
|
106 |
+
if (currentClass != newClass) {
|
107 |
+
wdi_front.ajaxLoader(currentFeed);
|
108 |
+
var colNum = newClass.substr(8, newClass.length);
|
109 |
+
|
110 |
+
//clearing wrapper adn adding blank colums
|
111 |
+
wrapper.html('');
|
112 |
+
var newCols = '';
|
113 |
+
for (var i = 0; i < colNum; i++) {
|
114 |
+
newCols += '<div class="wdi_masonry_column" wdi_mas_col="' + i + '"></div>';
|
115 |
+
}
|
116 |
+
newCols += '<div class="clear">';
|
117 |
+
wrapper.html(newCols);
|
118 |
+
|
119 |
+
//resetting index variables
|
120 |
+
currentFeed.imageIndex = 0;
|
121 |
+
currentFeed.resIndex = 0;
|
122 |
+
|
123 |
+
//inserting content again
|
124 |
+
|
125 |
+
//fix sorting issue;
|
126 |
+
var dataToBeDisplayed = currentFeed.displayedData;
|
127 |
+
currentFeed.displayedData = [];
|
128 |
+
wdi_front.masonryDisplayFeedItems(dataToBeDisplayed, currentFeed);
|
129 |
+
wdi_front.applyFilters(currentFeed);
|
130 |
+
wdi_front.allImagesLoaded(currentFeed);
|
131 |
+
|
132 |
+
|
133 |
+
}
|
134 |
+
}
|
135 |
+
//////////////////////////////////////////
|
136 |
+
if (currentClass != newClass) {
|
137 |
+
var colNum = newClass.substr(8, newClass.length);
|
138 |
+
//updating free spaces for pagination view
|
139 |
+
if (currentFeed.feed_row.feed_display_view == 'pagination') {
|
140 |
+
currentFeed.freeSpaces = (Math.floor(currentFeed.feed_row.number_of_photos / Math.round(containerWidth / itemWidth)) + 1) * Math.round(containerWidth / itemWidth) - currentFeed.feed_row.number_of_photos;
|
141 |
+
if (currentFeed.freeSpaces % colNum == 0) {
|
142 |
+
currentFeed.freeSpaces = 0;
|
143 |
+
}
|
144 |
+
//updating pagination indexes for new layout
|
145 |
+
currentFeed.resIndex = 0;
|
146 |
+
var k = 0;
|
147 |
+
jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + ' .wdi_feed_item').each(function ()
|
148 |
+
{
|
149 |
+
jQuery(this).attr('wdi_res_index', currentFeed.resIndex);
|
150 |
+
if ((k + 1) % currentFeed.feed_row.pagination_per_page_number === 0) {
|
151 |
+
currentFeed.resIndex += currentFeed.freeSpaces + 1;
|
152 |
+
} else {
|
153 |
+
currentFeed.resIndex++;
|
154 |
+
}
|
155 |
+
k++;
|
156 |
+
});
|
157 |
+
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
|
162 |
+
});
|
163 |
+
|
164 |
+
}
|
165 |
+
|
166 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
};
|
168 |
+
wdi_responsive.bindCaptionEvent = function (imgtitle, currentFeed)
|
169 |
+
{
|
170 |
+
//if(typeof imgtitle == "undefined") return;
|
171 |
|
172 |
+
// imgtitle.on('click',function(e){
|
173 |
+
// wdi_responsive.showCaption(jQuery(this),currentFeed);
|
174 |
+
// })
|
175 |
}
|
176 |
+
wdi_responsive.bindMasonryCaptionEvent = function (imgtitle, currentFeed)
|
177 |
+
{
|
178 |
+
//console.log("asdasd");
|
179 |
+
// imgtitle.on('click',function(){
|
180 |
+
// wdi_responsive.showMasonryCaption(jQuery(this),currentFeed);
|
181 |
+
// });
|
182 |
}
|
183 |
+
wdi_responsive.showCaption = function (caption, currentFeedCounter)
|
184 |
+
{
|
185 |
+
var currentFeed = window["wdi_feed_" + currentFeedCounter]
|
186 |
+
var imgItem = caption.parent().parent();
|
187 |
+
if (currentFeed.feed_row.feed_display_view === 'pagination') {
|
188 |
+
var indexType = 'wdi_res_index';
|
189 |
+
} else {
|
190 |
+
var indexType = 'wdi_index';
|
191 |
+
}
|
192 |
+
var imgIndex = imgItem.attr(indexType);
|
193 |
+
var colClass = jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + ' .wdi_feed_wrapper').attr('wdi-res');
|
194 |
+
var colNum = parseInt(colClass.substr(8, colClass.length));
|
195 |
+
var imgBeforRows = Math.floor(imgIndex / colNum);
|
196 |
+
var indexInRow = imgIndex - colNum * imgBeforRows;
|
197 |
+
|
198 |
+
var indexes = [];
|
199 |
+
|
200 |
+
for (var i = 0; i < colNum; i++) {
|
201 |
+
var rowIndex = i + (imgBeforRows) * colNum;
|
202 |
+
indexes.push(rowIndex);
|
203 |
+
|
204 |
+
|
205 |
+
}
|
206 |
+
|
207 |
+
if (imgItem.hasClass('wdi_full_caption')) {
|
208 |
+
caption.css('white-space', 'nowrap');
|
209 |
+
imgItem.removeClass('wdi_full_caption');
|
210 |
+
|
211 |
+
//jQuery('body, html').animate({scrollTop:imgItem.attr('wdi_scroll_to')}, '500');
|
212 |
+
//console.log("showCaption")
|
213 |
+
} else {
|
214 |
+
caption.css('white-space', 'normal');
|
215 |
+
imgItem.addClass('wdi_full_caption');
|
216 |
+
imgItem.attr('wdi_scroll_to', imgItem.offset().top - 50);
|
217 |
+
}
|
218 |
+
imgItem.css('height', 'auto');
|
219 |
+
|
220 |
+
//find maximum height in row
|
221 |
+
var maxHeight = 0;
|
222 |
+
for (var i = 0; i < indexes.length; i++) {
|
223 |
+
var currentItem = jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + ' .wdi_feed_wrapper [' + indexType + '=' + indexes[i] + ']');
|
224 |
+
currentItem.addClass('wdi_row_affected');
|
225 |
+
currentItem.css('height', 'auto');
|
226 |
+
if (maxHeight < currentItem.height() && currentItem.hasClass('wdi_full_caption')) {
|
227 |
+
maxHeight = currentItem.height();
|
228 |
+
}
|
229 |
+
}
|
230 |
+
|
231 |
+
if (maxHeight == 0) {
|
232 |
+
maxHeight = imgItem.height();
|
233 |
+
}
|
234 |
+
|
235 |
+
for (var i = 0; i < indexes.length; i++) {
|
236 |
+
var currentItem = jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + ' .wdi_feed_wrapper [' + indexType + '=' + indexes[i] + ']');
|
237 |
+
currentItem.height(maxHeight);
|
238 |
+
}
|
239 |
+
currentFeed.affectedRow = true;
|
240 |
|
241 |
}
|
242 |
+
wdi_responsive.fixRow = function (currentFeed)
|
243 |
+
{
|
244 |
+
jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + ' .wdi_row_affected').each(function ()
|
245 |
+
{
|
246 |
+
jQuery(this).css('height', 'auto');
|
247 |
+
jQuery(this).removeClass('wdi_row_affected');
|
248 |
+
});
|
249 |
+
if (currentFeed.feed_row.feed_display_view === 'pagination') {
|
250 |
+
jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + ' .wdi_full_caption').each(function ()
|
251 |
+
{
|
252 |
+
if (!jQuery(this).hasClass('wdi_hidden')) {
|
253 |
+
//triggering two times one time for fixing row second for bringing back old state
|
254 |
+
jQuery(this).find('.wdi_photo_title').trigger(wdi_front.clickOrTouch);
|
255 |
+
jQuery(this).find('.wdi_photo_title').trigger(wdi_front.clickOrTouch);
|
256 |
+
}
|
257 |
+
});
|
258 |
+
} else {
|
259 |
+
jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + ' .wdi_full_caption').each(function ()
|
260 |
+
{
|
261 |
+
//triggering two times one time for fixing row second for bringing back old state
|
262 |
+
jQuery(this).find('.wdi_photo_title').trigger(wdi_front.clickOrTouch);
|
263 |
+
jQuery(this).find('.wdi_photo_title').trigger(wdi_front.clickOrTouch);
|
264 |
+
});
|
265 |
+
}
|
266 |
+
|
267 |
+
|
268 |
}
|
269 |
|
270 |
+
wdi_responsive.showMasonryCaption = function (caption, currentFeedCounter)
|
271 |
+
{
|
272 |
+
var currentFeed = window["wdi_feed_" + currentFeedCounter];
|
273 |
+
|
274 |
+
var imgItem = caption.parent().parent();
|
275 |
+
|
276 |
+
if (imgItem.hasClass('wdi_full_caption')) {
|
277 |
+
caption.css('white-space', 'nowrap');
|
278 |
+
imgItem.removeClass('wdi_full_caption');
|
279 |
+
//jQuery('body, html').animate({scrollTop:imgItem.attr('wdi_scroll_to')}, '500');
|
280 |
+
} else {
|
281 |
+
imgItem.attr('wdi_scroll_to', imgItem.offset().top - 50);
|
282 |
+
caption.css('white-space', 'normal');
|
283 |
+
imgItem.addClass('wdi_full_caption');
|
284 |
+
}
|
285 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://web-dorado.com/products/wordpress-instagram-feed-wd.html
|
|
4 |
Tags: : custom instagram feed, feed, instagram, hashtag, Instagram feed, instagram gallery, instagram posts, Instagram images, Instagram photos, Instagram wall, lightbox, photos
|
5 |
Requires at least: 3.9
|
6 |
Tested up to: 4.6
|
7 |
-
Stable tag: 1.1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -107,6 +107,11 @@ After downloading the ZIP file of the Instagram Feed WD plugin,
|
|
107 |
|
108 |
== Changelog ==
|
109 |
|
|
|
|
|
|
|
|
|
|
|
110 |
= 1.1.11 =
|
111 |
Added: Setting to show media descriptions in widget mode (PRO)
|
112 |
Fixed: Untranslatable strings in widget editor
|
4 |
Tags: : custom instagram feed, feed, instagram, hashtag, Instagram feed, instagram gallery, instagram posts, Instagram images, Instagram photos, Instagram wall, lightbox, photos
|
5 |
Requires at least: 3.9
|
6 |
Tested up to: 4.6
|
7 |
+
Stable tag: 1.1.12
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
107 |
|
108 |
== Changelog ==
|
109 |
|
110 |
+
= 1.1.12 =
|
111 |
+
New: Feed based on liked media (Pro)
|
112 |
+
Fixed: Hidden media in last page
|
113 |
+
Fixed: Minor issues
|
114 |
+
|
115 |
= 1.1.11 =
|
116 |
Added: Setting to show media descriptions in widget mode (PRO)
|
117 |
Fixed: Untranslatable strings in widget editor
|
update/wdi_update.php
CHANGED
@@ -80,7 +80,9 @@ function wdi_update_diff($new_v, $old_v = 0.0){
|
|
80 |
$wpdb->query("ALTER TABLE " . $wpdb->prefix . WDI_THEME_TABLE . " convert to character set latin1 collate latin1_general_ci");
|
81 |
}
|
82 |
|
83 |
-
|
|
|
|
|
84 |
|
85 |
}
|
86 |
|
80 |
$wpdb->query("ALTER TABLE " . $wpdb->prefix . WDI_THEME_TABLE . " convert to character set latin1 collate latin1_general_ci");
|
81 |
}
|
82 |
|
83 |
+
if(version_compare($old_v, "1.12", '<')){
|
84 |
+
$wpdb->query("ALTER TABLE " . $wpdb->prefix . WDI_FEED_TABLE . " ADD `liked_feed` varchar(30) NOT NULL DEFAULT 'userhash'");
|
85 |
+
}
|
86 |
|
87 |
}
|
88 |
|
wd-instagram-feed.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Instagram Feed WD
|
4 |
Plugin URI: https://web-dorado.com/products/wordpress-instagram-feed-wd.html
|
5 |
Description: WD Instagram Feed is a user-friendly tool for displaying user or hashtag-based feeds on your website. You can create feeds with one of the available layouts. It allows displaying image metadata, open up images in lightbox, download them and even share in social networking websites.
|
6 |
-
Version: 1.1.
|
7 |
Author: WebDorado
|
8 |
Author URI: https://web-dorado.com
|
9 |
License: GPLv2 or later
|
@@ -20,7 +20,7 @@ define("WDI_META", "_".WDI_VAR."_meta");
|
|
20 |
//define("wdi",'wdi');
|
21 |
define('WDI_FEED_TABLE','wdi_feeds');
|
22 |
define('WDI_THEME_TABLE','wdi_themes');
|
23 |
-
define('WDI_VERSION','1.1.
|
24 |
define('WDI_IS_PRO','false');
|
25 |
|
26 |
|
3 |
Plugin Name: Instagram Feed WD
|
4 |
Plugin URI: https://web-dorado.com/products/wordpress-instagram-feed-wd.html
|
5 |
Description: WD Instagram Feed is a user-friendly tool for displaying user or hashtag-based feeds on your website. You can create feeds with one of the available layouts. It allows displaying image metadata, open up images in lightbox, download them and even share in social networking websites.
|
6 |
+
Version: 1.1.12
|
7 |
Author: WebDorado
|
8 |
Author URI: https://web-dorado.com
|
9 |
License: GPLv2 or later
|
20 |
//define("wdi",'wdi');
|
21 |
define('WDI_FEED_TABLE','wdi_feeds');
|
22 |
define('WDI_THEME_TABLE','wdi_themes');
|
23 |
+
define('WDI_VERSION','1.1.12');
|
24 |
define('WDI_IS_PRO','false');
|
25 |
|
26 |
|